refresh eclipse cdt system includes - eclipse

I'm using ecipse cdt developing c++ program. A problem is I moved all my workspace and eclipse package from turbolinux to centos linux. Then it cause a problem, that is system includes are different, but eclipse didn't refresh the include paths. And all the std container classes can not be solved.
Anyone know how to fix this problem?

I was recently bitten by this one myself (actually came to this site in search of an answer ;-) so I'll share what I found:
(these steps reflect Eclipse Indigo SR1)
First, double-check that Eclipse still reflects the old include paths:
project -> properties -> C/C++ General -> Paths and Symbols -> GNU C++
Next, clear the old paths:
project -> properties -> C/C++ Build -> Discovery Options -> GCC C++ Compiler
click the button for "Clear discovered entries now"
Rebuild your project, such that Eclipse picks up on the new include paths
Confirm that the new include paths are set:
project -> properties -> C/C++ General -> Paths and Symbols -> GNU C++

Checked for Eclipse Luna 4.4.0 with Cdt 8.4.0.201406111759.
You may have a look to your workspace/.metadata/.plugins/org.eclipse.cdt.core/ and check for a file named like YourProjectName.language.settings.xml.
Delete this file (better should backup before), then reopen your project (or restart Eclipse) and Cdt should trigger the the GCC Builtin Discovery.
Note that this way may only applyable if your settings are set to project specific Builtin Discovery (not for »Use global provider shared between projects«). → see Project Properties → C/C++ General → Preprocessor Include Paths, Macros etc. → Providers → CDT GCC Built-in Compiler Settings.
For older Eclipse versions (IMHO about until Indigo), the scanner cache files were placed in workspace/.metadata/.plugins/org.eclipse.cdt.make.core/ and named like YourProjectName.sc.

In the newest Eclipse CDT Mars.1 Release (4.5.1) you'll have to delete the ${WORKSPACE}/.metadata/.plugins/org.eclipse.cdt.core/${PROJECTNAME}.randomnumbers.pdom file, and after opening the project, Eclipse should automatically start to reindex the includes.

Related

Eclipse C++'s compiler version

I'm using the Eclipse IDE for C++ (Eclipse CDT). I want to install the SFML library but I can't find what version of GCC my Eclipse uses.
Note: I have multiple GCC compilers (versions) installed on my computer.
Or how can I set up a different compiler for Eclipse to use?
FWIW,
to supplement the existing answer, "Look at your compiler's messages,"
and to address the first of the two questions, essentially, "What version/installation of GCC is Eclipse presently using?",
borrowing heavily from [https://www.jblopen.com/gcc-toolchain-eclipse-setup-guide-part-2/][JBLopen], and to render future access to that link less significant, a helpful place to start for finding the default path(s) to the toolchain(s) used by Eclipse is this:
"Window" (menu item) -> Preferences -> (under General is) C/C++ (expand to see) -> Core Build Toolchains.
This system presently shows five entries:
/usr/bin/gcc
/usr/bin/c99-gcc
/usr/bin/c89-gcc
/usr/bin/x86_64-linux-gnu-gcc
/usr/bin/clang
Also, under Properties (menu item) (or File -> Properties, when the Project Name is selected in that "view"), -> C/C++ Build (expand to see) -> Tool Chain Editor. This doesn't give paths, but it provides clues as to which tools are being used. (If, in studying those, one clicks "No ToolChain" and can't get the drop-down list back, just click "Cancel," and that drop-down list will be available, again.)
Also, another clue, not directly a path, but a clue, in this Linux set-up, comes from Properties -> Linux Tools Path. which, for these current settings, indicates "Use the System Environment PATH".
Just to touch on the second question, there are processes for installing other compilers and toolchains. That part is findable via web search. Once another compiler, etc., is installed, back under Window -> Preferences -> C/C++ -> Core Build Toolchains, Eclipse provides a way to add User Defined Toolchains.
Linux 18.04
Eclipse (C/C++) 2019-03
You can check the -v (verbose) flag on in the project options, then compile any file. It'll cause gcc to print a lot of additional information as output, including version e.g.: gcc version 7.2.0. It also includes library search paths which should help you deduce where your compiler is located.
This flag is located under project properties -> C/C++ Build -> Settings -> Tool Settings (tab) -> Selected compiler -> Miscellaneous -> Verbose (-v).
As for which compiler is selected - it is generally taken from your PATH. System path is read by Eclipse upon startup. You can then go ahead and modify it by hand either on workspace level (Window -> Preferences -> C/C++ -> Build -> Environment) or on project level, for example if you wanted to use different compiler versions for different projects. The approach I use is to make sure that path to my toolchain is not added to system PATH and I add it by hand on the workspace level.

Disable auto discover of include paths in Eclipse

I have a self contained project where every included file is within the project itself.
In the project properties -> "C/C++ General" -> "Preprocessor Include Paths, Macros etc." -> "Providers" I disabled the entries I don't need, but something re-enables the "CDT Cross GCC Built-in Compiler Settings".
Is there a way to permanently disable this option?
I want to keep the indexer working, and also I have some entries in the CDT managed build entries so its not an option to get rid of the build configuration (I do not build/start the build of the project from Eclipse).
The automatically added includes conflicts with the files within my project messing up the indexer (it adds the MinGW includes).
I am using Eclipse Oxygen on Windows 7.

C++11 in Eclipse Without Specifying "-std=c++11" for Each Project

I'm using Eclipse Kepler for C++, and I'm trying to update to C++11.
I've found that appending "-std=c++11" under C/C++ Build -> Settings -> Miscellaneous -> Other Flags will enable a specific project to run C++11. However, I have not been able to find a way to default this operation whenever a new project is created.
Is there a one-time setting that automatically sets a new C++ project to C++11? Thanks for letting me know.

Who can tell me what's different of the project type in Eclipse CDT?

I just install CDT plugin in Eclipse. When i start a project by click New menu in Eclipse, it shows lots of C/C++ project type:
such as: Executable/Excetuable(XL UPC)/Shared Library/Shared Library(XL UPC)....
What's different between them?
These are essentially "presets" - they have slightly different default build settings. E.g. shared library will pass the linker settings to emit .so instead of executable, XL UPC projects use compiler different then GCC by default, etc.
These settings can be changed after the project is created - but it may require a good understanding of CDT.

moved my mingw installation - now eclipse cdt can't resolve the includes

I went to Project->Properties->C/C++ General->Paths and Symbols and indeed the paths are the ones of my old mingwin install. My question is : is there an easy way to tell eclipse to reset the toolchain - for the workspace not per project ? Of course when I installed the CDT having already mingwin in my PATH I did not configure anything manually and I'd like to avoid it now
Thanks
Found an answer here. Go to Project > properties > C/C++ General > Paths and Symbols > GNU C++ - you will notice the paths point to old installation. Clear them in Project > properties > C/C++ Build > Discovery Options > GCC C++ Compiler and press the Clear button in the Automated discovery of paths and symbols box by the Clear discovered entries now label.
Rebuild your project.
Valid for Eclipse Juno.
If someone could explain how to do this not on a per project basis but for the whole workspace (the clean up of the settings) it would be much appreciated (and accepted). The paths are hardcoded in ${workspace_loc}\.metadata\.plugins\org.eclipse.cdt.make.core\<project_name>.sc files - the usual total epic mess with eclipse prefs being scattered all over the place - grr. Would the answer to my original question be to search and replace the paths there (and only there ?) ?
EDIT : Of note are the items in Project > Index menu - maybe a more appropriate way to do the same thing ?
The settings changed in release 8.1 (Eclipse Juno) and can be set globally for all projects. At least that's what they advertised.
In Window > Preferences > C/C++ > Build > Settings, select CDT GCC Built-in Compiler Settings MinGW then Clear Entries and Reset. In my version (CDT 8.2, Eclipse Kepler), the project specific settings Discovery Options does not exist anymore.
Some links about this:
http://wiki.eclipse.org/CDT/User/NewIn81#Scanner_Discovery
http://wiki.eclipse.org/CDT/User/FAQ#What_is_a_Scanner_Discovery.3F
In my specific case, it did work but no for everything, and not for the most important the Path and Symbols settings. I had to manually edit the <project_name>.sc file in the workspace.
Hope this helps someone else.
Matt