标签:
下载地址:
http://ftp.gnu.org/gnu/gcc/gcc-4.6.1/
如果下载的是gcc-g++-4.6.1.tar.bz2编译,就会出错,因为gcc-g++只是gcc4.6.4的子集,文件不全的:
fdr@fdr-desktop:~/soft_libs/gcc-4.6.1/libstdc++-v3$ ./configure
configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."
发现报错了,因为这个config是需要使用autoconf工具来根据平台的configure.ac生成的,
gcc需要GMP、MPFR、MPC这三个库,下载地址:
ftp://gcc.gnu.org/pub/gcc/infrastructure/
一般工具都安装在/usr/local/下面,应用程序安装在/opt/下面。我们使用configure时可以使用--prefix来指定软件的安装目录。
如果不配置该选项,安装后可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,
其它的资源文件放在/usr /local/share,比较凌乱。
gmp编译:
./configure --prefix=/usr/local/gmp-4.3.2
make
sudo make install
mpfr编译:
./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2
make
sudo make install
mpc编译:
./configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2
./configure --prefix=/usr/local/mpc-0.8.2 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2
make
sudo make install
安装libtool2.2.6a(但是要求的是2.2.7a,版本必须匹配)
ftp://ftp.gnu.org/gnu/libtool/
./configure
make
sudo make install
安装路径是:
/usr/local/bin/libtoolize
/usr/local/bin/libtool
然后将libtool拷贝到gcc-4.6.1/host-i686-pc-linux-gnu/lto-plugin下面
测试发现下载2.2.8版本也不行。
但是2.2.6a版本虽然要报错,但是重新cp到指定目录也没问题了。
应该最好是下载2.2.7a版本:
ftp://ftp.linux.ee/pub/gnu/cygwin/release/libtool/libtool-2.2.7a-10-src.tar.bz2
安装PPL0.11
./configure
make
make install
安装路径是:
/usr/local/include
/usr/local/lib
Polylib的下载安装:
http://icps.u-strasbg.fr/PolyLib/polylib_src/?C=M;O=D
下载的源码编译不过,有错误。需要改动源码:
改成:
./configure
sudo make
sudo make install
安装路径是:
/usr/local/include
/usr/local/lib/
安装cloog0.15.9
下面是下载链接:
http://ftp.osuosl.org/pub/clfs/conglomeration/cloog-ppl/
http://repo.or.cz/cloog.git/tags
但是这里面就没有提供0.15.*的版本。
于是在csdn上面搜索到了:
(0.15.10版本有问题)
cloog依赖gmp和polylib(可选的)。
./configure --with-gmp=/usr/local/gmp-4.3.2 --with-polylib=/usr/local --with-ppl=/usr/local/
make
sudo make install
安装路径是:
/usr/local/include/
/usr/local/lib
报错1:
fdr@fdr-desktop:~/soft_libs/gcc4.6.1/ref/cloog-ppl-0.15.10$ make
make: *** No rule to make target `m4/libtool.m4‘, needed by `Makefile.in‘. Stop.
0.15.10这个版本有问题。换0.15.11版本
报错2:
error: polylib/missing.h: No such file or directory
是需要ppl的支持,加上--with-ppl的参数
GCC编译:
1,配置:
./configure --prefix=/usr/local/gcc-4.6.1 -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1
./configure --prefix=/usr/local/gcc-4.6.1 -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.2 --with-ppl-include=/usr/local/include --with-ppl-lib=/usr/local/lib
2.指定lib路径
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.2/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib
sudo ln -s /usr/local/mpc-0.8.2/lib/libmpc.so.2 /lib/libmpc.so.2 (避免后面再报找不到该库的错误)
sudo ldconfig
3.添加libtool:
$ /usr/local/bin/libtoolize --force
4.编译:
sudo make
#为了加快编译,采用4线程编译
#sudo make -j4
5.check
sudo apt-get install autogen
sudo apt-get install dejagnu (因为要用runtest)
sudo make check
注意,在Running /home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/gcc/testsuite/gcc.c-torture/compile/compile.exp ...会执行很久时间。
6.安装
原来的gcc和gdb的路径是/usr/bin/gcc /usr/bin/gdb,而我们的gcc安装路径将会是在/usr/local/gcc-4.6.1
sudo make install
创建软连接到/usr/bin下面
编译报错解答:
报错1:
make[4]: Entering directory `/home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/host-i686-pc-linux-gnu/lto-plugin‘
/bin/sh ./libtool --tag=CC --tag=disable-static --mode=compile gcc -DHAVE_CONFIG_H -I. -I../.././lto-plugin -I../.././lto-plugin/../include -DHAVE_CONFIG_H -Wall -Werror -g -fkeep-inline-functions -c -o lto-plugin.lo ../.././lto-plugin/lto-plugin.c
/bin/sh: ./libtool: No such file or directory
但是我们是安装了libtool的:whereis libtool:
libtool: /usr/bin/libtool /usr/share/libtool /usr/share/man/man1/libtool.1.gz
因为他是直接使用./libtool的方式调用的,但是我们的libtool是直接安装到/usr/bin下面的,所以解决办法如下:
方法1:)把libtool拷贝到目录
/home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/host-i686-pc-linux-gnu/lto-plugin
即可
方法2:)
libtool介绍:
可以认为libtool是gcc的一个抽象,其包装了gcc(或者其他的编译器),用户无需知道细节,只要告诉libtool需要编译哪些库即可,libtool将处理库的依赖等细节。libtool只与后缀名为lo、la为的libtool文件打交道。
报错2:
make[5]: Entering directory `/home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/i686-pc-linux-gnu/libgomp‘
/bin/sh ./libtool --tag=CC --mode=compile /home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/host-i686-pc-linux-gnu/gcc/xgcc -B/home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/host-i686-pc-linux-gnu/gcc/ -B/usr/local/gcc-4.6.1/i686-pc-linux-gnu/bin/ -B/usr/local/gcc-4.6.1/i686-pc-linux-gnu/lib/ -isystem /usr/local/gcc-4.6.1/i686-pc-linux-gnu/include -isystem /usr/local/gcc-4.6.1/i686-pc-linux-gnu/sys-include -DHAVE_CONFIG_H -I. -I../.././libgomp -I../.././libgomp/config/linux/x86 -I../.././libgomp/config/linux -I../.././libgomp/config/posix -I../.././libgomp -Wall -Werror -ftls-model=initial-exec -march=i486 -mtune=i686 -Wc,-pthread -g -O2 -MT alloc.lo -MD -MP -MF .deps/alloc.Tpo -c -o alloc.lo ../.././libgomp/alloc.c
libtool: Version mismatch error. This is libtool 2.2.6b Debian-2.2.6b-2ubuntu1, but the
libtool: definition of this LT_INIT comes from libtool 2.2.7a.
libtool: You should recreate aclocal.m4 with macros from libtool 2.2.6b Debian-2.2.6b-2ubuntu1
libtool: and run autoconf again.
make[5]: *** [alloc.lo] Error 63
需要下载一个对应版本的libtool:ftp://ftp.gnu.org/gnu/libtool/
报错3:
error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
需要把mpc0.8.1换成0.8.2
报错3.1
我们把mpc已经换成0.8.2了,最后又开始报错:
fdr@fdr-desktop:~/soft_libs/gcc4.6.1/gcc-4.6.1/i686-pc-linux-gnu/libgcc$ cat config.log | grep error
xgcc: error: unrecognized option ‘-V‘
xgcc: fatal error: no input files
xgcc: error: unrecognized option ‘-qversion‘
xgcc: fatal error: no input files
/home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/host-i686-pc-linux-gnu/gcc/cc1: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
/home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/host-i686-pc-linux-gnu/gcc/cc1: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
由于已经取消了变量:LD_LIBRARY_PATH,故系统无法自动找到libmpc.so.2,采取了一个变通的方式,建立了一个软链接:
sudo ln -s /usr/local/mpc-0.8.2/lib/libmpc.so.2 /lib/libmpc.so.2
报错4:
通过config.log查看到的详细错误原因:conftest.c:10:19: error: ppl_c.h: No such file or directory
需要安装ppl还有cloog的库,ppl的下载地址是:
ftp://ftp.cs.unipr.it/pub/ppl/releases/
我们需要下载大于等于0.11版本的ppl,但是主版本不能变,只能是0
并在configure的时候指定--with-ppl-include --with-ppl-lib
$ sudo apt-get install libppl0.10-dev
$ sudo apt-get install libcloog-ppl-dev (这是0.15.8版本,无法使用)
cloog下载地址是:
http://gcc.gnu.org/wiki/CLooG-PPL
报错5:
conftest.c:16: error: ‘choke‘ undeclared (first use in this functio
查看config.log,可以看到:
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define LT_OBJDIR ".libs/"
| /* end confdefs.h. */
| #include "ppl_c.h"
| int
| main ()
| {
|
| #if PPL_VERSION_MAJOR != 0 || PPL_VERSION_MINOR < 11
| choke me
| #endif
|
| ;
| return 0;
| }
也就是PPL_VERSION_MAJOR 不是0或者说PPL_VERSION_MINOR小于了11就不支持。
所以PPL需要下载大于等于0.11版本的。
报错6:
conftest.c:15: error: ‘choke‘ undeclared (first use in this function)
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define LT_OBJDIR ".libs/"
| /* end confdefs.h. */
| #include "cloog/cloog.h"
| int
| main ()
| {
| #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 9
| choke me
| #endif
| ;
| return 0;
| }
也就是需要添加--with-cloog,并且保证下载的版本是0.15.9以上的
报错7:
checking for i686-pc-linux-gnu-gcc... /home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/host-i686-pc-linux-gnu/gcc/xgcc -B/home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/host-i686-pc-linux-gnu/gcc/ -B/usr/local/gcc-4.6.1/i686-pc-linux-gnu/bin/ -B/usr/local/gcc-4.6.1/i686-pc-linux-gnu/lib/ -isystem /usr/local/gcc-4.6.1/i686-pc-linux-gnu/include -isystem /usr/local/gcc-4.6.1/i686-pc-linux-gnu/sys-include
checking for suffix of object files... configure: error: in `/home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/i686-pc-linux-gnu/libgcc‘:
configure: error: cannot compute suffix of object files: cannot compile
See `config.log‘ for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1
查看错误信息:
cat /home/fdr/soft_libs/gcc4.6.1/gcc-4.6.1/i686-pc-linux-gnu/libgcc/config.log | grep error
原因是:
error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
需要libmpc.so创建一个软连接到/usr/lib下面,因为LD_LIBRARY_PATH被取消掉了
=====================================================================================
=====================================================================================
参考资料:
1 在redhat 5上编译jdk
1.1 出现错误:configure: error: cannot compute suffix of object files: cannot compile
需要将mpc、gmp和mpfr目录加入到环境变量中,在/etc/profile文件末尾加上:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-5.0.1/lib:/usr/local/mpfr-3.0.0/lib,注意修改目录,之后运行#source /etc/profile使其生效即可。
1.2 FreeType version 2.3.0 or higher is required.
强制卸载了freetype -2.2.1-28.el5_7.2
rpm –e –nodeps freetype -2.2.1-28.el5_7.2
应该值之前的freetype版本的影响。
1.3 error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
由于已经取消了变量:LD_LIBRARY_PATH,故系统无法自动找到libmpc.so.2,采取了一个变通的方式,建立了一个软链接:
ln -s /usr/local/mpc-0.8.1/lib/libmpc.so.2 /lib/libmpc.so.2
1.4 /usr/local/gcc-4.8.1/libexec/gcc/i686-pc-linux-gnu/4.8.1/cc1plus: error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory
同错误3类似。
1.5 /opt/jdkbuild/jdk7/hotspot/src/share/vm/oops/constantPoolOop.cpp:272:39: error: converting ‘false‘ to pointer type ‘methodOop‘ [-Werror=conversion-null]
if (cpool->cache() == NULL) return false; // nothing to load yet
^
cc1plus: all warnings being treated as errors
打了一个补丁:
http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/f457154eee8b
见说明:
http://mail.openjdk.java.net/pipermail/hotspot-dev/2012-July/006243.html
1.6 /lib/libmpfr.so.1: undefined reference to `__gmp_get_memory_functions‘
见:http://www.mpfr.org/faq.html#undef_ref1
中的解释,这种错误多见于将GMP 4.1.4升级到更高版本的时候,或者同一台机器上安装了多个版本的GMP。这种错误可能意味着你应用了GMP 4.2.x的Header,但应用了GMP 4.1.4的library。所以将原gmp卸载:
rpm –e –nodeps gmp-4.1.4-10.el5
1.7 libgmp.so.3: cannot open shared object file: No such file or directory
同错误1.3类似。
2 在ubuntu 12上编译jdk
参考资料:
1. http://www.kaifajie.cn/ubuntu/10272.html
2. http://hadwinzhy.gitcafe.com/blog/2013/01/21/compile-jdk/
2.1 ERROR: You seem to not have installed ALSA 0.9.1 or higher
不需要从ALSA官网下载alsa-dev和alsa-drive,
ubuntu提供包的
sudo apt-get install libasound2-dev
2.2 /usr/bin/gawk: not found
apt-get install gawk
2.3 ERROR: echo "*** This OS is not supported:" ‘uname -a‘; exit 1;
注释掉hotspot/make/linux/Makefile里面的checkOS
check_os_version:
#ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
# $(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
#endif
也可以最好的办法是在make参数后面添加 :
DISABLE_HOTSPOT_OS_VERSION_CHECK=OK
2.4 /opt/jdkbuild/jdk7/hotspot/src/share/vm/runtime/interfaceSupport.hpp:430:0: error: "__LEAF" redefined [-Werror]
打补丁:
http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/a6eef545f1a2
2.5 undefined reference to ‘snd_pcm_*’
见说明:
http://comments.gmane.org/gmane.comp.java.openjdk.build.devel/5311
打补丁:
http://mail.openjdk.java.net/pipermail/build-dev/2011-November/005188.html
这篇文章里也有说明。
2.6 cannot find -lX11
apt-get install libx11-dev
2.7 ../../../src/solaris/native/sun/awt/awt.h:38:27: fatal error: X11/Intrinsic.h: No such file or directory
apt-get install libxt-dev
2.8 X11/extensions/shape.h: No such file or directory
apt-get install libxtst-dev
见说明:
http://www.csdnjava.com/forum.php?mod=viewthread&tid=147509
2.9 ../../../src/solaris/native/sun/awt/awt_p.h:51:36: fatal error: X11/extensions/Xrender.h: No such file or directory
apt-get install libxrender-dev
标签:
原文地址:http://blog.csdn.net/whyhowwhat/article/details/51908031