GunPointer
GunPointer

Reputation: 13

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?

Upvotes: 1

Views: 4456

Answers (2)

user13254313
user13254313

Reputation: 21

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

Upvotes: 2

J_S
J_S

Reputation: 3282

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.

Upvotes: 1

Related Questions