我读了这些线程:
使用gcc在Linux上运行线程构build模块(Intel TBB)
无法将Intel TBB库与libtbb链接到/ usr / lib中
即使在指定时,g ++也找不到标题
g ++找不到头文件
g ++找不到标题,但我确实包含它们
但仍然得到这个错误:
piCalc.cpp:8:17: fatal error: ttb.h: No such file or directory #include "ttb.h"
我的代码来计算pi开始
#include <iostream> #include "ttb.h" #include "parallel_for.h"
运行安装了nvidia和cuda的Ubuntu 14.04。 要安装TBB,我开始:
sudo apt-get install libtbb-dev
它说
Reading package lists... Done Building dependency tree Reading state information... Done libtbb-dev is already the newest version. The following package was automatically installed and is no longer required: libxine2-bin Use 'apt-get autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
所以我觉得我很好走。 所以,我试过了:
g++ piCalc.cpp -ltbb -o pi
并得到错误。 于是我从intel下载了这个档案,解压到我的主目录下,进入一个名为tbb的目录。
发出ls给出:
CHANGES COPYING README bin doc examples include index.html lib piCalc.cpp
注意piCalc.cpp在tbb目录中。 另外,tbb.h位于/ include / tbb所以我改变了include语句
#include <iostream> #include "/include/tbb/ttb.h" #include "/include/tbb/parallel_for.h"
libtbb.so和libtbb.so.2位于lib / intel64 / gcc4.4
我的terminal命令是这样发出的:
g++ piCalc.cpp -o pi -I include/tbb -L lib/intel64/gcc4.4 -ltbb
以及
g++ piCalc.cpp -o pi -I include/tbb/ -L lib/intel64/gcc4.4/ -ltbb
以及
g++ piCalc.cpp -o pi -I /include/tbb -L /lib/intel64/gcc4.4 -ltbb
并发生相同的错误
piCalc.cpp:8:30: fatal error: /include/tbb/ttb.h: No such file or directory #include "/include/tbb/ttb.h"
我用这个绝对path:
g++ piCalc.cpp -I /home/stefan/tbb/include/tbb -L /home/stefan/tbb/lib/intel64/gcc4.4 -ltbb -o pi
还是一样的错误。
我试着改变我的代码:
#include <iostream> #include </home/stefan/tbb/include/tbb/ttb.h> #include </home/stefan/tbb/include/tbb/parallel_for.h>
并得到这个:
stefan@HN5:~/tbb$ g++ piCalc3.cpp -I /home/stefan/tbb/include/tbb -L /home/stefan/tbb/lib/intel64/gcc4.4 -ltbb -o pi piCalc3.cpp:8:46: fatal error: /home/stefan/tbb/include/tbb/ttb.h: No such file or directory #include </home/stefan/tbb/include/tbb/ttb.h> ^ compilation terminated.
基本上相同的错误,但更详细,因为我在terminal命令中使用绝对path。
我想也许LD_LIBRARY_PATHvariables是重要的。 CUDA与LD_LIBRARY_PATHvariables混淆,所以我导出了intel libs和现在的printenv显示:
LD_LIBRARY_PATH=/home/stefan/tbb/lib/intel64/gcc4.4:/usr/local/cuda-7.5/lib64:
仍然得到错误。
这是详细的错误:
stefan@HN5:~/tbb$ g++ piCalc.cpp -o pi -v -I/home/stefan/tbb/include/tbb -L/home/stefan/tbb/lib/intel64/gcc4.4 -ltbb Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.1) COLLECT_GCC_OPTIONS='-o' 'pi' '-v' '-I' '/home/stefan/tbb/include/tbb' '-L/home/stefan/tbb/lib/intel64/gcc4.4' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -quiet -v -I /home/stefan/tbb/include/tbb -imultiarch x86_64-linux-gnu -D_GNU_SOURCE piCalc.cpp -quiet -dumpbase piCalc.cpp -mtune=generic -march=x86-64 -auxbase piCalc -version -fstack-protector -Wformat -Wformat-security -o /tmp/ccHq7bTl.s GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04.1) version 4.8.4 (x86_64-linux-gnu) compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8" ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/stefan/tbb/include/tbb /usr/include/c++/4.8 /usr/include/x86_64-linux-gnu/c++/4.8 /usr/include/c++/4.8/backward /usr/lib/gcc/x86_64-linux-gnu/4.8/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04.1) version 4.8.4 (x86_64-linux-gnu) compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 83f8d9bb238019ed17000f1b7e141e5a piCalc.cpp:8:30: fatal error: /include/tbb/ttb.h: No such file or directory #include "/include/tbb/ttb.h" ^ compilation terminated.
如果我将包含所有.h文件的include / tbb文件夹复制到/ usr / local / include文件夹中,我也会得到这个错误。 我也尝试括号,而不是在包含源文件的报价。
由于现在我的大脑已经深陷内心,所以我希望有人能帮我指出我所缺less的。
最后,我想通了,所以我张贴在这里,任何人都可能受益。
1) download the Intel libraries from [here][1] 2) extract the folder and rename it to tbb 3) move that folder into /usr/local 4) in source use: #include <tbb/tbb.h> 5) g++ test.cpp -o program -ltbb