0

On an OS X machine (Snow Leopard, if it matters), I'm attempting to upgrade from gcc 4.2.1 to 4.7.3.

I followed instructions here and here, and can now compile code using either -std=c++0x or std=c++11 from the command line.

But Eclipse CDT still appears to be using the old gcc version. I edited my project so that it has std=c++0x as a miscellaneous argument to the compiler. And yet, when I do a build within CDT I get the following output:

07:48:16 **** Build of configuration Debug for project 4.1 Valuation ****
make all 
Building file: ../src/BondModel.cpp
cc1plus: error: unrecognized command line option "-std=c++0x"
make: *** [src/BondModel.o] Error 1
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -MMD -MP -MF"src/BondModel.d" -MT"src/BondModel.d" -o "src/BondModel.o" "../src/BondModel.cpp"

07:48:16 Build Finished (took 109ms)

if I copy and paste that g++ line to terminal, it runs fine.

What do I need to change in eclipse so that it uses the installed and selected version of gcc?

Community
  • 1
  • 1
sharakan
  • 6,821
  • 1
  • 34
  • 61

1 Answers1

0

The answer has to do with where MacPorts puts gcc, as opposed to where XCode puts it.

  • MacPorts: /opt/local/bin/gcc
  • XCode: /usr/bin

So even after you install a later version of gcc with MacPorts, eclipse still uses the old one.

After finding this in this question, I fixed this by changing the compiler and linker in Project Properties->C/C++ Build->Settings->Tool Settings, MacOS X C++ Linker and GCC C++ Compiler to have as their command /opt/bin/local/g++ instead of g++.

This did not completely resolve my issues, because the CDT UI is still complaining about C++ 11 features, but I can build my project and run it.

Community
  • 1
  • 1
sharakan
  • 6,821
  • 1
  • 34
  • 61
  • Were you able to solve the problem with CDT UI (e.g., syntax highlighting and code completion)? – betabandido Sep 16 '13 at 18:56
  • I have managed to fix the issue with CDT UI :) You can see what I did [here](http://stackoverflow.com/questions/18086835/using-clang-for-code-analysis-in-an-autotools-project-in-eclipse). – betabandido Sep 19 '13 at 01:05