我在MinGW32下(在Windows 7 64位上)构建TBB并成功地将一个简单的程序链接到它.不幸的是,我的同事无法成功链接.我们都运行相同版本的Windows,相同版本的MinGW(mingw-get-inst-20110802),并试图编译完全相同的代码.我们的PATH环境变量完全相同(.:/ usr/local/bin:/ mingw/bin:/ bin).然而,尽管所有事情都是平等的(据我所知),我可以成功构建和运行程序,我的同事尝试在链接步骤失败了.如果我给他他的tbb.dll,那么他可以成功链接他的程序.因此,我被引导相信他的tbb.dll的构建有问题.我们已经确认(使用文件)我们正在为所有目标文件和库生成32位二进制文件
$ file a.exe
a.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit
$ file ./tbb/tbb30_20110704oss/lib/tbb.dll
./tbb/tbb30_20110704oss/lib/tbb.dll: PE32 executable for MS Windows (DLL) (console) Intel 80386 32-bit
Run Code Online (Sandbox Code Playgroud)
我们用于构建TBB的命令行是:
mingw32-make compiler=gcc arch=ia32 runtime=mingw tbb
Run Code Online (Sandbox Code Playgroud)
我们正在编译的简单测试程序是:
#include <tbb/task_scheduler_init.h>
using namespace tbb;
int main() {
task_scheduler_init init;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我们用来构建简单测试程序的命令行
g++ test1.cpp -I ./tbb/tbb30_20110704oss/include -L ./tbb/tbb30_20110704oss/lib -ltbb
Run Code Online (Sandbox Code Playgroud)
就我而言,它可以完美地构建和链接.在他的情况下,他收到错误消息:
test1.o: In function `tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)':
test1.cpp:(.text._ZN3tbb19task_scheduler_initC1Eij[tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)]+0x33): undefined reference to `tbb::task_scheduler_init::initialize(int, unsigned int)'
test1.o: In function …Run Code Online (Sandbox Code Playgroud) 在研究一些新的C++ 11特性时,我观察到一些与新的decltype关键字及其与条件运算符的交互相关的奇怪之处.
我很惊讶地看到以下程序的输出:
#include <iostream>
#include <map>
int main(void)
{
// set up a map that associates the internal compiler-defined type_info name with a human readable name
std::map <std::string, std::string> types;
types[typeid(decltype(static_cast<unsigned char >(0))).name()] = "unsigned char";
types[typeid(decltype(static_cast<unsigned short >(0))).name()] = "unsigned short";
types[typeid(decltype(static_cast<short >(0))).name()] = "short";
types[typeid(decltype(static_cast<unsigned int >(0))).name()] = "unsigned int";
types[typeid(decltype(static_cast<int >(0))).name()] = "int";
types[typeid(decltype(static_cast<float >(0))).name()] = "float";
types[typeid(decltype(static_cast<double >(0))).name()] = "double";
types[typeid(decltype(static_cast<bool >(0))).name()] = "bool";
std::cout << "Should be unsigned char : " << types[typeid(decltype(static_cast<unsigned char …Run Code Online (Sandbox Code Playgroud)