简体   繁体   English

如何在mac上的Eclipse CDT上编译C ++ 0x代码?

[英]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): 在OSX上的Eclipse CDT中使用C ++ 0x(在托管make项目中):

  • Open the project properties 打开项目属性
  • C/C++ Build 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) 将“MacOS X C ++链接器”和“GCC G ++编译器”中的“命令”字段从g ++更改为c ++(在检查c ++是clang ++与shell中的“c ++ --version”之前)
  • Add "-std=c++0x -stdlib=libc++" in the "Miscellaneous" parameters of "GCC G++ Compiler" 在“GCC G ++编译器”的“其他”参数中添加“-std = c ++ 0x -stdlib = libc ++”
  • Add "-stdlib=libc++" in the MIscellaneous "Linker flags" parameters of "MacOS X C++ Linker" 在“MacOS X C ++ Linker”的MIscellaneous“Linker flags”参数中添加“-stdlib = libc ++”
  • Open the "Discovery options", select the "GCC C++ compile" change g++ to c++ and add -std=c++0x to the "Compiler invocation arguments" 打开“发现选项”,选择“GCC C ++编译”将g ++更改为c ++,并将“-std = c ++ 0x”添加到“编译器调用参数”
  • Add "/usr/include/c++/v1" to the "includes" in "Paths and Symbols" in C/C++ General 将“/ usr / include / c ++ / v1”添加到C / C ++ General的“路径和符号”中的“包含”中

The latest Apple gcc compiler is gcc 4.2 which does not support C+11 code. 最新的Apple gcc编译器是gcc 4.2,它不支持C + 11代码。 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. 你需要安装一个gcc 4.6 - 这可以从源代码完成,或者在hpc上有一些二进制文件,这将gcc放在/ usr / local / bin中然后在eclipse中的C ++编译器的首选项中使用它。

Alternative for Lion and above Xcode 4.* includes clang the latest version of which doies much of C+11 Lion和Xcode 4的替代品。*包括clang最新版本的C + 11大部分内容

If you want a later gcc macports (and fink and homebrew) have a later version as a port. 如果你想要一个以后的gcc macports(和fink和homebrew)有一个更高版本的端口。 As of July 2012 macports has 4.7.1 and a 4.8 beta. 截至2012年7月,macports有4.7.1和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. 包管理器通常是将复杂的编译代码放到您的机器上的最简单方法,它们也有集中编译的版本,默认情况下会下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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