简体   繁体   中英

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

有人可以指向标志和设置更改,以便在Mac上的Eclipse CDT上编译C ++ 0x代码吗?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM