Ajeet Ganga
Ajeet Ganga

Reputation: 8653

How to compile a C++0x code on Eclipse CDT on mac?

Can someone point to flags and setup changes required for one to compile C++0x code on a Eclipse CDT on mac please ?

Upvotes: 2

Views: 2956

Answers (2)

mmmmmm
mmmmmm

Reputation: 32661

The latest Apple gcc compiler is gcc 4.2 which does not support C+11 code. You need to install a gcc 4.6 - this can be done from source or there are some binaries at hpc this put the gcc in /usr/local/bin Then use that in the preferences fot the C++ compiler in eclipse.

Alternative for Lion and above Xcode 4.* includes clang the latest version of which doies much of C+11

If you want a later gcc macports (and fink and homebrew) have a later version as a port. As of July 2012 macports has 4.7.1 and a 4.8 beta. The package managers are often the easiest way to get complex compiled code onto your machine and they also have centrally compiled versions that will be downloaded by default.

Upvotes: 3

Marco
Marco

Reputation: 2479

To use C++0x in Eclipse CDT on OSX (in a managed make project):

  • Open the project properties
  • C/C++ Build
  • Settings
  • Change the "Command" field in "MacOS X C++ Linker" and in "GCC G++ Compiler" from g++ to c++ (before check that c++ is clang++ with "c++ --version" in a shell)
  • Add "-std=c++0x -stdlib=libc++" in the "Miscellaneous" parameters of "GCC G++ Compiler"
  • Add "-stdlib=libc++" in the MIscellaneous "Linker flags" parameters of "MacOS X C++ Linker"
  • Open the "Discovery options", select the "GCC C++ compile" change g++ to c++ and add -std=c++0x to the "Compiler invocation arguments"
  • Add "/usr/include/c++/v1" to the "includes" in "Paths and Symbols" in C/C++ General

Upvotes: 6

Related Questions