问题描述
我读了这些主题:
但仍然出现此错误:
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,我从:
Running Ubuntu 14.04 with nvidia and cuda installed.To install TBB, I started with :
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.
所以我以为我很好.所以,我尝试了:
So I thought I was good to go. So, I tried:
g++ piCalc.cpp -ltbb -o pi
并得到错误.因此,我从intel下载了归档文件,并将其解压缩到我的主目录下,命名为tbb.
and get the error. So I downloaded the archive from intel and decompressed it to my home directory into a directory named tbb.
发出ls会给出:
CHANGES COPYING README bin doc examples include index.html lib piCalc.cpp
注意piCalc.cpp在tbb目录中.另外,tbb.h位于/include/tbb所以我将include语句更改为
Notice piCalc.cpp is in the tbb directory. Also, tbb.h is located at /include/tbbSo I changed the include statements to
#include <iostream>
#include "/include/tbb/ttb.h"
#include "/include/tbb/parallel_for.h"
libtbb.so和libtbb.so.2位于lib/intel64/gcc4.4
libtbb.so and libtbb.so.2 are located at lib/intel64/gcc4.4
我的终端命令是这样发出的:
My terminal command was issued thusly:
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"
我尝试了以下绝对路径:
I tried absolute paths with this:
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.
基本上相同的错误,但是更冗长,因为我在终端命令中使用了绝对路径.
Basically the same error but more verbose since I used the absolute path in the terminal command.
我认为LD_LIBRARY_PATH变量可能很重要. CUDA弄乱了LD_LIBRARY_PATH变量,因此我导出了Intel库,现在printenv显示了:
I thought maybe the LD_LIBRARY_PATH variable was important. CUDA messes with the LD_LIBRARY_PATH variable so I exported the intel libs and now printenv shows:
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文件夹中,也会遇到此错误.我还尝试使用方括号代替源文件中包含文件的引号.
I also get this error if I copy the include/tbb folder which has all the .h files into the /usr/local/include folder. I also tried brackets instead of quote for the include files in the source.
由于现在我的大脑已陷入深深的车辙,所以我希望有人可以指出我所缺少的东西来为我提供帮助.
Since my brain is in a deep rut by now, I am hoping someone can help me by pointing out what I am missing.
推荐答案
最后,我想通了,所以我在这里发布,以便其他任何人都可以受益.
FINALLY, I figured it out so I am posting here so anyone else might benefit.
- 从此处下载
- 提取文件夹并将其重命名为tbb
- 将该文件夹移动到
/usr/local
- 在源代码中使用:
#include <tbb/tbb.h>
-
g++ test.cpp -o program -ltbb
- Download the Intel libraries from here
- Extract the folder and rename it to tbb
- Move that folder into
/usr/local
- In source use:
#include <tbb/tbb.h>
g++ test.cpp -o program -ltbb
这篇关于链接INTEL TBB库时遇到麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!