Eclipse Juno with CDT Doesn't Add Built-in Include Directories

丶灬走出姿态 提交于 2019-12-21 03:32:37

问题


Since I upgraded from Eclipse Indigo to Juno (on Ubuntu 12.04), I've been having the problem where it shows "unresolved inclusion" errors for standard libraries (e.g. next to #include <iostream> and #include <vector>, etc.), although the program builds and runs fine (using g++). This only occurs in new projects created with Juno, not old ones from Indigo in my workspace.

Thanks to several other SO questions (see below*), I was able to trace the source of the problem to the absence of the "built-in values" in a project's Properties > C/C++ General > Paths and Symbols > Includes tab:

/usr/include/c++/4.6
/usr/include/c++/4.6/x86_64-linux-gnu
/usr/include/c++/4.6/backward
/usr/lib/gcc/x86_64-linux-gnu/4.6/include
/usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include 

are present when the "Show built-in values" checkbox is ticked in my old Indigo projects that didn't have this problem, but are absent in my new projects created with Juno. Sure enough, if I add these seven directories manually to the Includes tab in a project's settings, the problem disappears. But I don't want to have to do this manually for every new project I create. Is there a reason this is no longer the default in Juno, and is there a way to restore it?

*Other SO questions with similar issues I have consulted but did not solve my problem:

  • Eclipse 3.7.0 Indigo with CDT shows many false compilation errors: I thought Erzsébet Geréb's answer would be my solution -- in Juno, if I create a new C++ project with "Project type" as one of the categories under "GNU Autotools" instead of "Executable," the built-in directories are there. (In Indigo, there's no GNU Autotools category. If I created it in Indigo as an empty or Hello World project under "Executable," those directories are there, but they're not if I do it that way in Juno -- I have to pick an option under "GNU Autotools.") But then, with a "GNU Autotools" project, when I go to the project's Properties > C/C++ Build > Settings, the "Tool Settings" tab is no longer present and I am unable to add include paths for the GCC C++ Compiler and libraries for the GCC C++ Linker, which I need to do because many of my C++ projects use OpenCV libraries.
  • "Unresolved inclusion" error with Eclipse CDT for C standard library headers: Told me how to add the include paths manually, but not how to have the built-in ones added by default
  • error , Symbol 'vector' could not be resolved: Cleaning ~/.eclipse/ and rebuilding index didn't help.
  • Eclipse CDT Builtin Include Directories: Discovery Options are set the same as my projects that do work properly.
  • eclipse CDT 8.01 - default paths (libstdc,libstdc++) totally disappeared in 'includes' directory
  • Eclipse CDT indexer lost after system update: Doesn't solve the problem for all new projects.

回答1:


Please

  • Open the Eclipse Preferences dialog (Windows | Preferences).
  • Open C++ | Build | Settings.
  • Open the Discovery tab.
  • Select the built-in compiler settings entry.
  • Press the Clear Entries button.

Afterwards eclipse should request the defaults again from the compiler.

On Arch Linux I had to do this after each GCC version change, because in that case the locations for the defaults changed as the version is encoded in the folder name, and eclipse does not notice this.




回答2:


FWIW:

I found that after importing a project from another computer, I was not getting any thing showing up under the "Includes" section of my project in the Project Explorer. To fix this, I needed to delete the folder /workspace/project/.settings/. For me it only had one file (language.settings.xml).

Then everything was back to normal.



来源:https://stackoverflow.com/questions/16259616/eclipse-juno-with-cdt-doesnt-add-built-in-include-directories

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