问题
I followed the instructions at https://sites.google.com/site/dwhipp/tutorials/mac_compilers for OSX Lion and XCode 4.3 to use g++ on the command line, but when I run it I get this:
jeff~/Dropbox/cpp$ g++ hello.cpp
ld: unknown option: -no_compact_unwind
collect2: error: ld returned 1 exit status
回答1:
If you want to use the latest version of GCC (4.7) by command line on Mac OS X Lion, I have a better solution.
Install MacPorts (you can download the source code and compile it or download the pkg installer):
http://www.macports.org/install.php
Installed MacPort, open the Terminal and type (you need the root password)
sudo port selfupdate
for updating the port tree. Then type
sudo port install gcc47 +universal
This command will install the GCC 4.7 compiler on your Mac (this compilation will take a lot of time, be patient). Now you have your GCC 4.7 compiler accessible by the command line under the name
gcc-mp-4.7
(use g++-mp-4.7
for C++ compilation). You have also the new C++11 standard adding the option
g++-mp-4.7 -std=c++11
来源:https://stackoverflow.com/questions/12022543/using-g-on-osx-lion-ld-unknown-option-no-compact-unwind