使用cygwin 编译gcc 4.7.2

作者在 2013-01-27 23:08:18 发布以下内容

首先我得说一个跟gcc没任何关系,但却是每个cygwin使用者必须知道的东西,那就是rebaseall。
这个跟cygwin在windows上模拟出unix的fork函数的实现有关。在cygwin中安装了新包,或者更新了旧包,都可能导致fork发生问题,而fork在unix血统的程序中又是那么地常用。
一旦出了什么你觉得不该出的问题,在尝试解决之前,首先rebaseall一下,很有可能rebaseall之后一切就正常了。
如何rebaseall呢?
关闭所有的cygwin程序
然后Win+R
输入f:\cygwin\bin\ash.exe回车 (我的cygwin装在了F盘)
然后输入/bin/rebaseall
好啦,这就rebaseall完了。
一定记住了。
===============================================================


为了装gcc 4.7.2,得先装三个gcc所依赖的库,它们分别是:gmp, mprf, mpc
由于这三个库之间也有依赖关系,所以你得按我列出来的顺序依次安装

可于以下这些地方下载这三个库的源码包:
 http://gmplib.org/                (我下的是gmp-5.0.5.tar.bz2)
http://mpfr.org/                     (我下的是mpfr-3.1.1.tar.bz2)
http://www.multiprecision.org/            (我下的是mpc-1.0.1.tar.gz)

下载下来后用tar -xf解开

修改~/.bash_profile,加入以下三行
export LD_LIBRARY_PATH=/usr/local/lib
export LIBRARY_PATH=/usr/local/lib
export CPATH=/usr/local/include
重启cygwin,让这三行生效。


编译gmp:
./configure --disable-static --enable-shared
make
make install

编译mpfr:
./configure --disable-static --enable-shared
make
make install

编译mpc:
./configure
make
make install

编译gcc 4.7.2
mkdir gcc-4.7.2-objdir
cd gcc-4.7.2-objdir
../gcc-4.7.2/configure  --prefix=/usr/local/gcc-4.7.2  --enable-languages=c,c++  --disable-bootstrap
make
make install

最后编辑.bash_profile,将gcc 4.7.2的可执行文件所在目录加入PATH环境变量
PATH="/usr/local/gcc-4.7.2/bin:$PATH"


参考:http://cygwin.wikia.com/wiki/How_to_install_a_newer_version_of_GCC

linux | 阅读 7446 次
文章评论,共4条
vfdff(作者)
2013-01-27 23:09
1
然后Win+R 开启命令行的快捷方式
vfdff(作者)
2013-01-27 23:12
2
D:\Program_Files\cygwin\bin\ash.exe
并输入:/bin/rebaseall
vfdff(作者)
2013-01-27 23:18
3
Angelo Graziosi schrieb: 
I want to flag that when I 'rebaseall' it says:

/usr/lib/clisp-2.44/full+gtk2/svm.so: skipped because nonexistent

Is it to be expected? 
Yes.
This file is from the not updated clisp-gtk2-2.44-2 package.

vfdff(作者)
2013-01-28 00:01
4
http://ftp.gnu.org/gnu/gcc/gcc-4.7.2/
游客请输入验证码
浏览1943189次