编译器不知道我的包含文件

时间:2012-05-15 11:59:50

标签: c++ compilation include g++

我正在使用g ++和jamroot文件(jamroot.jam)编译我的项目。我不知道为什么它不知道我的文件,即使它包含正确的目录。

这是输出:

"g++"  -ftemplate-depth-128 -O0 -fno-inline -Wall -g -fPIC  -DLINUX  \
  -I"/home/oumaya/docs/UT_Cpp_Test/main/inc" \
  -I"/home/oumaya/docs/UT_Cpp_Test/main/inc/include/cppunit" \
  -I"/home/oumaya/docs/UT_Cpp_Test/main/inc/include/cppunit/ui/qt" \
  -I"/usr/share/boost" -c -o "bin/build/gcc-4.6/debug/src/main.o" "src/main.cpp"

In file included from src/main.cpp:6:0:
/home/oumaya/docs/UT_Cpp_Test/main/inc/UT_Instrument_Test.hpp:7:45: fatal error:
  cppunit/extensions/HelperMacros.h :  No such file or directory  

5 个答案:

答案 0 :(得分:2)

你错过了一个:

-I/home/oumaya/docs/UT_Cpp_Test/main/inc/include/

原因是你包括这样:

#include "cppunit/extensions/HelperMacros.h"

,完整路径是

/home/oumaya/docs/UT_Cpp_Test/main/inc/include/cppunit/extensions/HelperMacros.h

因此你应该告诉已编译的cppunit/extensions/HelperMacros.h

的相对路径

答案 1 :(得分:2)

您正在为输入文件指定[...]inc/include/cppunit路径,但是将标头引用为cunit/extensions/HelperMacros.h这意味着编译器期望路径相对于[...]inc/include/cppunit并最终以{{1 }}。您只需为include目录指定[...]inc/include/cppunit/cunit/extensions/HelperMacros.h(或将标题路径更改为[...]inc/include

答案 2 :(得分:2)

比较

你的命令 -

-I"/home/oumaya/docs/UT_Cpp_Test/main/inc/include/cppunit"

错误消息:

fatal error: cppunit/extensions/HelperMacros.h : No such file or directory

即,“include root”应该在/home/oumaya/docs/UT_Cpp_Test/main/inc/include,而不是“cppunit”子目录(显然在#include指令中声明)。

或者,您的#include声明有误,并且cppunit/前面不应有extensions/HelperMacros.h

答案 3 :(得分:1)

它根本无法找到该文件。您尝试包含cppunit/extensions/HelperMacros.h,因此请浏览构建输出中的所有-I包含路径,看看它们是否连接到该文件的有效路径。他们不会错过你的目录。

下一步是通过cppunit安装并找到您的文件:

find <cppunit root> -name HelperMacros.h

如果找到以cppunit/extensions/HelperMacros.h include结尾的那个,请删除该位,并使用路径的第一部分作为编译命令的额外-I包含路径。

答案 4 :(得分:0)

运行Ubuntu时,我发现你只需用

安装正确的东西即可

对于cppunit / extensions / HelperMacros.h或cppunit / BriefTestProgressListener.h:

sudo apt-get install libcppunit-dev
相关问题