Eclipse CDT: Unresolved inclusion of stl header

删除回忆录丶 提交于 2019-12-17 10:35:09

问题


I'm trying to use Eclipse to edit sources, compiled under C++ Builder, but stuck with Unresolved inclusion problem.

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.

Eclipse IDE gives no error if I write

#include <vector.h>

How do I tell Eclipse to use vector.h when it sees #include <vector>?


回答1:


This allowed me to avoid Eclipse "Unresolved inclusion" error.

In my case I had to find the location of the C++ vector header on my computer (which is a Mac):

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:

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.




回答2:


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.

None of the other solutions (play with include path, etc) worked for me for the type 'string', but this one fixed it.




回答3:


memory and memory.h don't refer to the same source.

One is for c, the other for c++

Do you have the right includes source in your project settings ?




回答4:


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:

  • 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:
    • Go to "C/C++ Build" - "Tool Chain Editor" and select "Cygwin GCC" as the "Current toolchain":
    • Go to "C/C++ General" - "Preprocessor Include Paths, Macors etc.", in the "Providers" tab, select:
      • "CDT Users Setting Entries" (I need them for other includes, such as the Google Test ones, which I manually referenced);
      • "CDT GCC Built-in Compiler Settings Cygwin".


来源:https://stackoverflow.com/questions/5977542/eclipse-cdt-unresolved-inclusion-of-stl-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!