Pee*_*eet 3 c++ visual-studio include-path
我正在使用其他人编写的库,它有点基于 C 用于 C++ 用法-我认为-。头文件或源文件中使用的所有包含内容都采用 <> 而不是 "" 的形式,即使它们不是标准库文件。我的编译器无法识别它们并返回错误“找不到文件”
问题的一个示例位于以下标题中:
#ifndef _ga_ga_h_
#define _ga_ga_h_
// Make sure that we get the configuration into each of the galib components
// that will be used.
#include <ga/gaconfig.h>
// These are the headers for all of the genetic algorithm classes.
#include <ga/GASimpleGA.h>
#include <ga/GASStateGA.h>
#include <ga/GAIncGA.h>
#include <ga/GADemeGA.h>
#include <ga/GADCrowdingGA.h>
// Here we include the headers for all of the various genome types.
#include <ga/GA1DBinStrGenome.h>
#include <ga/GA2DBinStrGenome.h>
#include <ga/GA3DBinStrGenome.h>
#include <ga/GABin2DecGenome.h>
Run Code Online (Sandbox Code Playgroud)
我使用 #include "ga.h" 在我的程序中包含该头文件,但很难在库中的每个头文件/源文件中更改。
有没有办法让编译器像使用“”一样使用 <>?我尝试从项目属性中添加到“添加包含目录”的路径(我使用的是 Visual Studio),许多包含的错误消失了,但大约 30 个仍然存在。奇怪的是,它们在一个名为“c1xx”的文件中,但我没有那个文件!!
谢谢,
定义有点像 <> 用于“系统”头文件,通常在 /usr/include(在类 Unix 系统上)等位置找到,而 "" 用于本地头文件。当你编译你的代码时,你可以指定包含头文件的附加目录的位置,例如在使用 GCC 时使用 -I 选项。检查编译器的文档以了解所需的设置
因此,例如在 Linux 和 GCC 上,如果您的“ga”目录在 /usr/local/include/ga 中,您将使用 cc -I /usr/local/include。