简体   繁体   English

<>中包含的文件找不到“”中​​包含的文件

[英]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.

相关问题 Xcode不会检测包含文件中main中包含的文件 - Xcode won't detect files included from main in included file 为什么 my.cpp 文件无法识别包含在 .h 文件中的变量? - Why is my .cpp file can't recognize variables from included in .h file? 读取相对于包含文件的文件 - Reading a file relative to an included file Qt Creator Clang Code Model can't find included header in included header - Qt Creator Clang Code Model can't find included header in included header vscode intellisense 找不到包含在 cmake 项目中的 header 文件 - vscode intellisense can't find header files included in cmake project 沮丧-编译器无法在我包含的标题中找到函数 - Frustrated - Compiler Can't Find A Function In My Included Header 即使已包含,g ++也找不到此方法 - g++ can't find this method even though it's included 查找的确切位置 <included> 编译时使用C ++文件 - Find exact location of <included> file in C++ at compilation time 如何找到包含文件的“命名空间关键字”? - How do I find the 'namespace keyword' of an included file? 尝试在 Unix 上安装并行 IO,出现错误:无法打开包含的文件 &#39;mpif.h&#39; - Trying to install Parallel IO on Unix, getting Error: Can't open included file 'mpif.h'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM