[英]g++ makefile, include error, no such file or directory
I am trying to include the following headers: 我想包括以下标题:
#include <libs/serialization/example/portable_binary_iarchive.hpp>
#include <libs/serialization/example/portable_binary_oarchive.hpp>
These files are located in a path like: 这些文件位于以下路径中:
/home/nobody/boost_1_45_0/libs/serialization/example/portable_binary_iarchive.hpp
In my Makefile, I have added: 在我的Makefile中,我添加了:
-I/home/nobody/boost_1_45_0/libs
However, when I compile, I get the error messages like: 但是,当我编译时,我收到如下错误消息:
error: libs/serialization/example/portable_binary_iarchive.hpp: No such file or directory
Can anybody tell me what I am doing wrong here? 谁能告诉我这里我做错了什么? I am also including boost libraries like
我也包括像你这样的boost库
#include <boost/archive/binary_oarchive.hpp>
However, to get those, it is sufficient to do in my Makefile: 但是,要获得这些,只需在我的Makefile中执行:
-I/usr/include/boost
Why doesn't this work for the headers in the other location? 为什么这不适用于其他位置的标头? How should I change my Makefile?
我应该如何更改我的Makefile? The first statement current looks like this:
第一个语句当前如下:
test: test.o
g++ -O3 -ffast-math -funroll-loops -ansi -pedantic-errors -L/usr/lib -lboost_filesystem -lboost_serialization -lboost_iostreams -lz -I/usr/include/boost -I/home/nobody/boost_1_45_0/libs -o test test.o
To get 要得到
#include <libs/serialization/example/portable_binary_iarchive.hpp>
from directory 来自目录
/home/nobody/boost_1_45_0/libs/serialization/example/portable_binary_iarchive.hpp
your Makefile needs 你的Makefile需要
-I/home/nobody/boost_1_45_0
Notice that I omitted the /libs
from the end. 请注意,我从末尾省略了
/libs
。 That's because your #include
directive already lists that directory. 那是因为你的
#include
指令已经列出了那个目录。
As for your second example, is the file you want at this location: 至于你的第二个例子,是你想要在这个位置的文件:
/usr/include/boost/boost/archive/binary_oarchive.hpp
^^^^^ (repeated boost here)
If not g++ is likely defaulting to /usr/include
as the search space for 如果不是g ++可能默认为
/usr/include
作为搜索空间
#include <boost/archive/binary_oarchive.hpp>
Ie., your 就是你的
-I/usr/include/boost
is useless to the compiler. 对编译器没用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.