How to use g++ in terminal in mac?

筅森魡賤 提交于 2019-12-13 15:35:05

问题


I've installed Xcode and I can compile .cpp files in Xcode. However, I wanna use g++ in Terminal but command not found: g++ now.
My OS is Mountain Lion Xcode version is 4.4.


回答1:


You need to download and install the Command Line Tools for OSX Mountain Lion from Apple Developer (you'll need a Apple ID which is free to sign up for). This will install GCC (including g++) so you can build direct from Terminal

The exact package currently is Command Line Tools (OS X Mountain Lion) for Xcode - September 2012

Description about the package from Apple:

This package enables UNIX-style development via Terminal by installing command line developer tools, as well as Mac OS X SDK frameworks and headers. Many useful tools are included, such as the Apple LLVM compiler, linker, and Make. If you use Xcode, these tools are also embedded within the Xcode IDE, and can be installed on your system using the Downloads preferences pane within Xcode 4.5.




回答2:


Note that when you run "g++" with Xcode 4.5 installed, you're picking up llvm-g++-4.2 (based on gcc 4.2.1) -- a provided, but no longer supported compiler on the platform. I'd strongly recommend using clang++ instead, the actively supported/developed compiler on the platform.



来源:https://stackoverflow.com/questions/12652701/how-to-use-g-in-terminal-in-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!