为了账号安全,请及时绑定邮箱和手机立即绑定

go语言编译环境gccgo的搭建过程

标签:
Go


gcc新版本编译gccgo

前提条件:

GNU Multiple Precision Library (GMP) version 4.3.2 (or later)

Necessary to build GCC. If a GMP source distribution is found in a subdirectory of your GCC sources named gmp, it will be built together with GCC. Alternatively, if GMP is already installed but it is not in your library search path, you will have to configure with the --with-gmp configure option. See also --with-gmp-lib and --with-gmp-include. 

MPFR Library version 2.4.2 (or later)

Necessary to build GCC. It can be downloaded from http://www.mpfr.org/. If an MPFR source distribution is found in a subdirectory of your GCC sources named mpfr, it will be built together with GCC. Alternatively, if MPFR is already installed but it is not in your default library search path, the --with-mpfr configure option should be used. See also --with-mpfr-lib and --with-mpfr-include. 

MPC Library version 0.8.1 (or later)

Necessary to build GCC. It can be downloaded from http://www.multiprecision.org/. If an MPC source distribution is found in a subdirectory of your GCC sources named mpc, it will be built together with GCC. Alternatively, if MPC is already installed but it is not in your default library search path, the --with-mpc configure option should be used. See also --with-mpc-lib and --with-mpc-include. 

一个一个顺序安装后,

a) 安装gmp

make 

make check 

make install 

b)  安装MPFR

c)  安装mpc  

需要提前在linux中或者windows中安装svn软件。

linux中安装subversion windows中安装TortoiseSVN

安装命令(一行一个命令):

svn checkout svn://gcc.gnu.org/svn/gcc/branches/gccgo gccgo

mkdir objdir

cd objdir

../gccgo/configure --enable-languages=c,c++,go

make

make install

make时的错误:

/webapp/project/objdir/x86_64-unknown-linux-gnu/libgcc':

configure: error: cannot compute suffix of object files: cannot compile

解决办法:从stackoverflow中查到的

This issue is caused by dyanmic link library path issue when the test programs try to link against libmpc/libmpfr/libgmp.

Append below environment variable to allow ld link against the correct so file:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mpc/lib/

Then try build gcc again.

耗时一个工作日,编译完成。

如此便可在内核版本很低,gcc版本为gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-55)的情况下,通过编译安装新版本的gcc version 5.0.0 20150116 (experimental) (GCC) ,直接编译go语言的源代码文件。编译命令类似c/c++的编译。如果有文件依赖关系,需要import non-standard package,使用如下命令即可:

go build -compiler gccgo main.go

©著作权归作者所有:来自51CTO博客作者dannypu的原创作品,如需转载,请注明出处,否则将追究法律责任


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消