在OSX Lion上使用g ++,ld:未知选项:-no_compact_unwind [英] Using g++ on OSX Lion, ld: unknown option: -no_compact_unwind
问题描述
我按照 https://sites.google.com/site/dwhipp上的说明操作/ tutorials / mac_compilers 用于OSX Lion和XCode 4.3在命令行上使用g ++,但是当我运行它时,我得到:
code> jeff〜/ Dropbox / cpp $ g ++ hello.cpp
ld:未知选项:-no_compact_unwind
collect2:错误:ld返回1退出状态
如果要在Mac OS X Lion上通过命令行使用最新版本的GCC ,我有一个更好的解决方案。
安装MacPorts(可以下载源代码并编译或下载pkg安装程序):
http://www.macports.org/install.php
安装MacPort,打开终端并输入(需要root密码)
sudo port selfupdate
用于更新端口树。然后输入
sudo port install gcc47 + universal
此命令将在Mac上安装GCC 4.7编译器(此编译将需要很多时间,请耐心等待)。现在你有你的GCC 4.7编译器可以通过命令行以名称
访问
gcc-mp-4.7
(对于C ++编译使用
g ++ - mp-4.7
)。您还有新的C ++ 11标准添加选项g ++ - mp-4.7 -std = c ++ 11
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
解决方案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 optiong++-mp-4.7 -std=c++11
这篇关于在OSX Lion上使用g ++,ld:未知选项:-no_compact_unwind的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!