【发布时间】:2015-04-20 17:38:37
【问题描述】:
在我的这个项目的 makefile 中,我为编译器指定了 3 个位置来查找#includes。
INCLUDES=-I. -I/home/kelly/xerces/xerces-c-3.1.1/src -I/home/kelly/Utilities_New
当我使用注释中的命令行编译以下示例代码时:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <xercesc/util/XMLString.hpp>
using namespace std;
/*
g++ -I. -I/home/kelly/xerces/xerces-c-3.1.1/src -I/home/kelly/Utilities_New test.cpp
*/
int main(int argc, char* argv[])
{
cout << "this works" << endl;
}
In file included from /home/kelly/Utilities_New/string.h:5:0,
from /home/kelly/xerces/xerces-c-3.1.1/src/xercesc/framework/XMLBuffer.hpp:28,
from /home/kelly/xerces/xerces-c-3.1.1/src/xercesc/util/XMLString.hpp:26,
from test.cpp:7:
/home/kelly/Utilities_New/defs.h:26:21: fatal error: windows.h: No such file or directory
compilation terminated.
很明显,编译器已经决定,当它处理 Xerces #includes 并在 Utilities_New 目录中找到 string.h 时,它已经找到了它需要的内容并停在那里。
另一个 string.h 是由另一个程序员编写的,我正在尝试使用他的库。
我认为首先搜索的是标准位置。我在这里有点迷路了。我可能遗漏了一些对你们来说非常明显的东西。
另外,关于#include 文件是否有一些规则,它们周围有 与 "" 以及编译器应该查看的位置?
【问题讨论】:
-
您可能正在与链接器标志作斗争,该标志表示默认使用或不使用标准库。快速浏览一下。
-
搜索路径 - "" 本地路径优先