[英]File included with <> can't find a file included with “”
I'm developing a library that is to be used (after compiled and installed) by another developer. 我正在开发一个供其他开发人员使用(编译和安装后)的库。 All my includes are like this:
我所有的包含都是这样的:
#include "../exception/CException.h"
All goes well but when I install the library and use it in another program with #include <> that include a file that have #include "../exception/CException.h" the last file is not found. 一切顺利,但是当我安装该库并将其用于包含#include“ ../exception/CException.h”的文件的#include <>另一个程序中时,找不到最后一个文件。 Why?
为什么?
Any help to improve include usage? 有任何改善使用率的帮助吗?
The problem with a relative path is that we don't know for sure what it is relative to. 相对路径的问题是我们不确定它相对于什么。 Different compilers have different ways of doing this.
不同的编译器执行此操作的方式不同。
You should rather use 你宁可使用
#include "yourlib/exception/CException.h"
similar to Boost. 类似于Boost。
If you install this as a subdirectory yourlib
in /usr/local
the compiler should be able to find that. 如果将其安装为
/usr/local
您的yourlib
的子目录,则编译器应该能够找到它。
You'll need to distribute ../exception/CException.h
with your library. 您需要将
../exception/CException.h
与您的库一起分发。 If it's really part of your library putting it in a subdirectory rather than a sibling would be preferable. 如果确实是您的库的一部分,则最好将其放在子目录中,而不要放在同级目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.