Eclipse C++'s compiler version - eclipse

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.

Related

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.

Eclipse CDT indexer does not know C++11 containers

I configured a C++11 project in Eclipse CDT to use gcc-4.7. It is not the default compiler on my system, which does not support C++11. In order for compilation to work, I need to pass the flag -std=c++11 and also include the following header path: /usr/local/Cellar/gcc/4.7.2/gcc/include/c++/4.7.2
Whenever I use C++11 container types like std::unordered_set or std::unordered_map, the CDT indexer complains: Symbol unordered_set could not be resolved. How can I tell the indexer to resolve these symbols correctly?
This is how I have configured my indexer:
As far as I understand the settings, the indexer is supposed to use the compiler settings from the currently active build configuration. Compilation works fine, so why doesn't indexing, too?
Setting up **__GXX_EXPERIMENTAL_CXX0X__** does not help in my case (Jul 2014, Eclipse Kepler 20130919, Ubuntu 12.04).
To fix C++11 syntax highlighting go to:
Project Properties --> C/C++ General --> Paths and Symbols --> Symbols --> GNU C++
and overwrite the symbol (i.e. add new symbol):
__cplusplus
with value
201103L
UPDATED: If you use newer version of Eclispe (as of 2016) and still experience the same problem, try value (as pointed by jose.diego):
201402L
Make sure that indexer is enabled in Project settings (C/C++ general --> Indexer)
Then reindex (Project --> C/C++ Index --> Rebuild)
if the problem still persist reindex once again. It should work now.
I solved this problem recently after some lucky googling.
Click on your project and right-click->Properties
Select "C/C++ General -> Processor Include Paths, Macros etc..."
Select the "Providers" tab
Deselect everything except "CDT User Setting Entries" and "CDT GCC Built-in Compiler Settings"
Click on "CDT GCC Built-in Compiler Settings"
Deselect "Use global provider shared between projects"
Edit the box at the bottom labeled "Command to get compiler specs"
Insert into the command -std=c++11 so it looks something like this:
${COMMAND} -std=c++11 -E -P -v -dD "${INPUTS}"
Click Apply and Okay.
That worked for me. You probably need to re-index the project.
As described in this forum post:
http://www.eclipse.org/forums/index.php/mv/msg/282618/
right-click the project and go to "Properties" C/C++ General -> Paths
and Symbols -> Symbols -> GNU C++.
Click "Add..." and paste __GXX_EXPERIMENTAL_CXX0X__ into "Name" and
leave "Value" blank. Hit Apply, do whatever it asks you to do, then
hit OK.
Or go to:
C/C++ Build->Discovery Options->GCC C++ Compiler
add your flags to the Compiler invocation arguments. like -std=c++11 -m32
Clear discovered entrys now: click on Clear
rebuild the project
After that ALL symbols will be updated with correct values and the indexer should work as intended
The workaround for me, with a project that uses an external builder, was to define the symbol:
__cplusplus
with the value:
201403
in the project's: Paths and Symbols -> Symbols/GNU C++.
This worked in eclipse Kepler CDT Version: 8.3.0.201402142303.
See this guide:
C/C++ Build->Settings->GCC C++ Compiler->Dialect
Choose "ISO C++11 (-std=c++0x)" in "language standard"
Apply and OK
Rebuild the project and it works:)
The follows works in Eclipse C/C++ Oxygen.2 with gcc-5.5.0
Eclipse Properties->C/C++ Build->Settings->GCC C++ Compiler->Dialect->Other dialect flags: -std=c++17
Don't pick up anything in the Language standard dropdown list.
The following configuration helps me to fix the issue indicated in the original question.
Environment:
Eclipse(Oxygen.3a Release (4.7.3a)), Cygwin64.
In case you have a different version of Cygwin, you can find similar directories as follows.
Step 1: Make sure you have the following two directories:
C:\cygwin64\lib\gcc\x86_64-pc-cygwin\7.4.0\include
C:\cygwin64\lib\gcc\x86_64-pc-cygwin\7.4.0\include\c++
If you don't see the above two directories, please launch your Cygwin setup program and install gcc-core, gcc-g++ and libgcc1.
Step 2: Copy the directory C:\cygwin64\lib\gcc\x86_64-pc-cygwin\7.4.0\include to C:\cygwin64\usr if you don't see above two include directories.
Step 3: Go to Project Property->C/C++ General->Paths and Symbols
Make sure you can see the following two paths are listed
C:\cygwin64\usr\include
C:\cygwin64\usr\include\c++
Step 4: Property->C/C++ Build/Settings/ Choose Cygwin PE Parser
Step 5: Property->C/C++ Build/Tool Chain Editor Choose Cygwin GCC
Step 6: Property->C/C++ General/Indexer Choose Enable indexer
Step 7: Project->C/C++ Index->Rebuild
Now your eclipse should be able to see the C++11 types.

Unresolved inclusion of Qt in Eclipse

Eclipse fails to locate Qt includes. Likewise, it fails to provide auto-complete functionality for Qt classes.
I did Project -> Properties -> Paths and Symbols -> Includes -> Add to the include directories of Qt in /usr/include/qt4/. This caused Eclipse to recognize certain certain classes such as QString; however, there is no auto-complete.
I have scoured the web to no avail. How do I make Eclipse index Qt into my project?
Edit: 12/20/12
I have solved my own problem. It appears order of the includes matter. I put
'usr/include/qt4'
'usr/include/qt4/Qt'
'usr/include/qt4/QtCore'
'usr/include/qt4/QtGui'
into Project Properties -> C++ General -> Paths & Symbols. I rebuilt and the auto-complete worked.
You need to add several include directories, those listed by e.g. the command
pkg-config --cflags QtGui QtXml QtSvg QtDBus
(and others Qt packages).

refresh eclipse cdt system includes

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.

Eclipse CDT Does not track macro defines correctly

In the build settings I have it define DEBUG when in the debug build configuration, so that I may make my code do separate things depending on which type of build it is.
However in Eclipse it darkens out the parts of the code which are excluded by the preprocessor, and this doesn't keep up when I change the setting (whether I'm currently building debug or release). So, I have a bunch of code which is perpetually darkened out, and the Eclipse indexer and other helpful features don't work inside of those areas.
How to fix? Has anyone else encountered this?
Update: Still having this issue. I eventually abandoned my unit-test build configs and simply put that functionality into a command-line switch. Just so that I could get indexing to work while I write my unit tests.
You have to set the option "Build configuration for the indexer" to "Use active build configuration" in the projects C/C++ indexer preferences. Open the properties panel for the project, go to c/C++ General and Indexer and enable project specific settings and change the radiobutton on the bottom to "Use Active build configuration".
Of course you can also set this in the global properties panel of Eclipse to change this setting for all projects.
Go to your project's Properties, then go to C/C++ General -> Paths and Symbols -> Symbols. Add your defines there and it will work.
If you want to change the defines for your system based on build configuration, you need to do as dgrant said here: "Project properties and select C/C++ General -> Paths and Symbols then select the Symbols tab", but you need to make sure you have the correct configuration selected at the top of your window. Also be sure when you add the symbol to the list that you DON'T check the "add to all configurations" checkbox.
If you want your correct set of symbols to be parsed by CDT in your editor, you'll also need to make sure you have the correct build configuration active as well. To do that, right-click on your project and select Build Configurations -> Set Active -> and select the build configuration you want to make active. CDT will now parse all the files as if this build configuration were active instead, using the global symbols you defined in the last step.
There is a problem I've seen with every version of Eclipse where it doesn't always decide to rebuild your index files immediately. To get it to do so, you can either start a build (the build doesn't actually have to complete), or you can right-click on your project and go to Index -> Rebuild. Both cause an immediate re-indexing to occur. You shouldn't need this, however. I can confirm that simply changing the build configuration as described in step 2 above will cause an #ifdef I have in my code which checks for a symbol defined only in one of my build configurations to immediately become greyed-out or un-greyed-out, as it should.
Check provider: -> C/C++ General -> Preprocessor Include Paths, Macros etc. -> Providers -> CDT Managed Build Settings Entries. It should be enabled.
Check if defined symbol is in entries of this provider.
Indexer is optional.
My satisfactory solution has been to move away from Eclipse to editors with a working libclang plugin: Sublime Text, Vim.
For an intelligent IDE for C/C++, one probably can't go wrong with XCode or MSVC.