简体   繁体   English

Eclipse CDT:未解决的stl标头包含

[英]Eclipse CDT: Unresolved inclusion of stl header

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. 给出了Unresolved inclusion: <vector> Eclipse IDE中的Unresolved inclusion: <vector>错误。 C++ Builder indeed has no vector file, instead it has vector.h which is used by compiler. 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> ? 当它看到#include <vector>时,如何告诉Eclipse使用vector.h

This allowed me to avoid Eclipse "Unresolved inclusion" error. 这让我避免了Eclipse“Unresolved inclusion”错误。

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". 我在文件夹“/usr/include/c++/4.2.1”中找到了正确的包含位置。 Then I set my project eclipse settings like so: 然后我设置我的项目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,但我的解决方案可能会解决您的部分麻烦。

You could also try use "CDT GCC Built-in Compiler Settings". 您也可以尝试使用“CDT GCC内置编译器设置”。 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. 转到项目属性> C / C ++常规>预处理器包含路径>提供程序选项卡,然后选中“CDT GCC内置编译器设置”(如果不是)。

None of the other solutions (play with include path, etc) worked for me for the type 'string', but this one fixed it. 没有其他解决方案(使用包含路径等)为我的类型'字符串'工作,但这个解决了它。

On Windows, with Eclipse CDT Oxygen, none of the solutions described here worked for me (including the "Provider" - "CDT GCC Built-in Compiler Settings"). 在Windows上,使用Eclipse CDT Oxygen,此处描述的解决方案都不适用于我(包括“提供程序” - “CDT GCC内置编译器设置”)。 What works for me is: 对我有用的是:

  • Install Cygwin, with notably the following packages (maybe not all are strictly needed for this): 安装Cygwin,尤其是以下软件包(可能并非所有软件包都是必需的):
    • libgcc1 中的libgcc1
    • cygwin32-gcc-core, cygwin32-gcc-g++ cygwin32-gcc-core,cygwin32-gcc-g ++
    • gcc-g++ GCC-克++
    • mingw64-x86_64-gcc-core, mingw64-x86_64-gcc-g++ mingw64-x86_64-gcc-core,mingw64-x86_64-gcc-g ++
  • In Project Properties: 在项目属性中:
    • Go to "C/C++ Build" - "Tool Chain Editor" and select "Cygwin GCC" as the "Current toolchain": 转到“C / C ++ Build” - “工具链编辑器”并选择“Cygwin GCC”作为“当前工具链”: 项目属性 - 工具链编辑器
    • Go to "C/C++ General" - "Preprocessor Include Paths, Macors etc.", in the "Providers" tab, select: 转到“C / C ++ General” - “预处理器包含路径,Macors等”,在“Providers”选项卡中,选择:
      • "CDT Users Setting Entries" (I need them for other includes, such as the Google Test ones, which I manually referenced); “CDT用户设置条目”(我需要它们用于其他包含,例如我手动引用的Google Test);
      • "CDT GCC Built-in Compiler Settings Cygwin". “CDT GCC内置编译器设置Cygwin”。 项目属性 - 提供者

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 ? 您是否在项目设置中拥有正确的包含来源?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM