C++ Eclipse CDT:未解决包含 stl 标头
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5977542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse CDT: Unresolved inclusion of stl header
提问by rmflow
I'm trying to use Eclipse to edit sources, compiled under C++ Builder, but stuck with Unresolved inclusion
problem.
我正在尝试使用 Eclipse 来编辑在 C++ Builder 下编译的源代码,但遇到了Unresolved inclusion
问题。
For example, code like:
例如,代码如下:
#include <vector>
Gives Unresolved inclusion: <vector>
error in Eclipse IDE. C++ Builder indeed has no vector
file, instead it has vector.h
which is used by compiler.
给Unresolved inclusion: <vector>
Eclipse IDE中的错误。C++ Builder 确实没有vector
文件,而是有vector.h
编译器使用的文件。
Eclipse IDE gives no error if I write
如果我写,Eclipse IDE 不会出错
#include <vector.h>
How do I tell Eclipse to use vector.h
when it sees #include <vector>
?
我如何告诉 Eclipsevector.h
在看到时使用它#include <vector>
?
回答by Christopher Bruns
This allowed me to avoid Eclipse "Unresolved inclusion" error.
这使我能够避免 Eclipse“未解决的包含”错误。
In my case I had to find the location of the C++ vector header on my computer (which is a Mac):
就我而言,我必须在我的计算机(这是一台 Mac)上找到 C++ 向量标头的位置:
find /usr/local -name vector -print
I found the correct include location in folder "/usr/include/c++/4.2.1". Then I set my project eclipse settings like so:
我在文件夹“/usr/include/c++/4.2.1”中找到了正确的包含位置。然后我像这样设置我的项目 eclipse 设置:
Project->Properties->C/C++ General->Paths and Symbols->GNU C++->(Add)->"/usr/include/c++/4.2.1"
I'm not using C++ Builder, but my solution might address part of your trouble.
我没有使用 C++ Builder,但我的解决方案可能会解决您的部分问题。
回答by Virtual
You could also try use "CDT GCC Built-in Compiler Settings". Go to the project properties > C/C++ General > Preprocessor Include Path > Providers tab then check "CDT GCC Built-in Compiler Settings" if it is not.
您也可以尝试使用“CDT GCC 内置编译器设置”。转到项目属性 > C/C++ General > Preprocessor Include Path > Providers 选项卡,然后检查“CDT GCC Built-in Compiler Settings”(如果不是)。
None of the other solutions (play with include path, etc) worked for me for the type 'string', but this one fixed it.
其他解决方案(使用包含路径等)都不适用于“字符串”类型,但是这个解决方案修复了它。
回答by Xavier Lamorlette
On Windows, with Eclipse CDT Oxygen, none of the solutions described here worked for me (including the "Provider" - "CDT GCC Built-in Compiler Settings"). What works for me is:
在 Windows 上,使用 Eclipse CDT Oxygen,此处描述的所有解决方案都不适用于我(包括“提供程序”-“CDT GCC 内置编译器设置”)。对我有用的是:
- Install Cygwin, with notably the following packages (maybe not all are strictly needed for this):
- libgcc1
- cygwin32-gcc-core, cygwin32-gcc-g++
- gcc-g++
- mingw64-x86_64-gcc-core, mingw64-x86_64-gcc-g++
- In Project Properties:
- 安装 Cygwin,特别是以下软件包(可能不是所有软件包都需要):
- libgcc1
- cygwin32-gcc-核心,cygwin32-gcc-g++
- gcc-g++
- mingw64-x86_64-gcc-核心,mingw64-x86_64-gcc-g++
- 在项目属性中:
回答by djfoxmccloud
memory and memory.h don't refer to the same source.
memory 和 memory.h 不是指同一个来源。
One is for c, the other for c++
一个用于 c,另一个用于 c++
Do you have the right includes source in your project settings ?
您的项目设置中是否有正确的包含源代码?