gpt4 book ai didi

c++ - 赛格温 : no header file found

转载 作者:行者123 更新时间:2023-11-30 03:32:15 25 4
gpt4 key购买 nike

以下问题:Cygwin 或 Visual Studio 报错。

 CGAL/Splitters.h: No such file or directory

每个标题都会出现此错误! header由代码实现

#include <CGAL/Splitters.h>

错误消失,如果我改变代码,这样我写了整个路径:

#include <c:/path1/path2/CGAL/Splitters.h>

但这不是让我满意的解决方案,因为我将不得不更改数百个这样的代码片段。我觉得应该是visual studio或者cygwin的问题。在 cygwin 中我写了命令:

$ g++ -std=c++11 example.cpp -o example

错误的原因是什么?我该如何解决?请给出简单易懂的说明,因为我是 C++ 的初学者。

最佳答案

编译器不知道去哪里找头文件由 #include <CGAL/Splitters.h> 提及除非你告诉它,因为该头文件不在任何编译器的头文件的默认搜索目录。

您通过向编译器传递一个 -I 来告诉编译器在哪里查找。选项:

$ g++ -I/path/to/cgal/headers -std=c++11 example.cpp -o example

头文件的位置:

/path/to/cgal/headers/CGAL/Splitters.h

进一步阅读:An Introduction to GCC - for the GNU compilers gcc and g++

稍后

So for every of the header files I have to write the - I option?

没有。 -I/path/to/cgal/headers/本身当然会告诉编译器在哪里可以找到程序中使用的每个 CGAL 头文件。

关于c++ - 赛格温 : no header file found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43619327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com