There are two possible answers, depending on whether you are doing "Standard Make" or "Mangaged Make". Standard Make means you are writing your own Makefiles and managing all that yourself. Managed Make means you are letting CDT create the Makefiles and manage them.
Standard Make
For standard make, everything is controlled by what the scanner discovers. The scanner handles finding all the system include files that are part of your project, and those are fed into the indexer to resolve symbols and also allows things like header file navigation.
To change the compiler that is used, you need replace ${COMMAND}
with your compiler of choice. It is up to you (as the user) to ensure that this command matches what you are using in your Makefile.
To change the ${COMMAND}
:
- Open Project Properties (by right-clicking on the project)
- Select C/C++ General -> Preprocessor Include Paths, Macros, etc in the tree.
- Select Providers tab
- Select CDT GCC Built-in Compiler Settings from the list
- Replace the
${COMMAND}
in Command to get compiler specs: to your desired g++ executable.
Here is a screenshot to help:
To see this in action, here are some screenshots with and without the change described. On my machine I have /usr/bin/g++
which is version 5.3 and /usr/bin/g++-4.7
which is version 4.7.
With default g++
With overridden g++ to version 4
Use Environment manage
The problem with the above is that you need to coordinate g++ between your Makefile and the build settings. One solution to this is to use the C/C++ Build Environment settings to define CXX
as the compiler to use. Set the CXX
environment variable in the project settings (Project Properties -> C/C++ Build -> Environment) or global preferences (Preferences -> C/C++ -> Build -> Environment).
Then replace ${COMMAND}
with ${CXX}
.
Here is a screenshot that demonstrates what I described:
Managed Make
If, instead, you are using Managed Make, you need to override the build settings for the individual tools. These settings then feed into the Preprocessor Include Paths, Macros, etc. settings as used directly by Standard Make.
To change the build settings, you need to override the command used for the compiler in a few places, once for each type of tool. Start in Project Properties -> C/C++ Build -> Settings and then edit each of these:
- GCC C++ Compiler -> Normally set to
g++
- GCC C Compiler -> Normally set to
gcc
- GCC C++ Linker -> Normally set to
g++
Here is a screenshot to demonstrate:
/usr/bin/cc
anywhere. – Cardiogram/opt/boost
which was compiled with GCC 4.9.3, but that shouldn't matter much). – Cardiogram