1.下载安装macports:http://www.macports.org/install.php
安装完成之后,打开终端
2.在终端中输入
port install gcc_select
3.使用
sudo port install gcc43
安装gcc编译器
4.使用
port select --list gcc
查看gcc的版本 mp-gcc43
5.设置gcc43为当前gcc的编辑器
sudo port select --set gcc mp-gcc43
至此已经可以使用gcc本身来编译代码了,不会再调用系统自带的编译器。
输入gcc -v查看版本号显示如下:
Using built-in specs.
Target: x86_64-apple-darwin13
Configured with: /opt/local/var/macports/build/_opt_mports_dports_lang_gcc43/gcc43/work/gcc-4.3./configure --prefix=/opt/local --build=x86_64-apple-darwin13 --enable-languages=c,c++,objc,obj-c++,java,fortran --libdir=/opt/local/lib/gcc43 --includedir=/opt/local/include/gcc43 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datadir=/opt/local/share/gcc43 --with-local-prefix=/opt/local --with-libiconv-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.3 --with-gxx-include-dir=/opt/local/include/gcc43/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --enable-stage1-checking --disable-multilib --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc43 4.3.6_11'
Thread model: posix
gcc version 4.3. (MacPorts gcc43 4.3.6_11)
但在编译gpxe时还是会报错:
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand '-' flag!
[BUILD] bin/__divdi3.o
/var/folders/mh/h89b9cns6_b2v7bg7n3nznk00000gn/T//ccvPQs37.s:31:Unknown pseudo-op: .equ
/var/folders/mh/h89b9cns6_b2v7bg7n3nznk00000gn/T//ccvPQs37.s:31:Rest of line ignored. 1st junk character valued 95 (_).
make: *** [bin/__divdi3.o] Error