编译出现<undefined reference to `_Unwind_Resume'>或<invalid option `tune=pentium4'>错误问题解决
Friday, 30. March 2007, 05:03:46

运行环境:
rhel es 4
Oracle 10g 10.1.0.3
=========================================================
在rhel es 4上安装fcgi-2.4.0,编译时出现如下错误:
g++ -g -O2 -o .libs/echo-cpp echo-cpp.o ../libfcgi/.libs/libfcgi++.so /home/nemo/build/fcgi-2.4.0/libfcgi/.libs/libfcgi.so -lnsl -Wl,--rpath -Wl,/usr/local/lib echo-cpp.o(.text+0x443): In function `main': /home/lee/build/fcgi-2.4.0/examples/echo-cpp.cpp:175: undefined reference to `_Unwind_Resume' collect2: ld returned 1 exit status make[2]: *** [echo-cpp] Error 1
还有就是安装ImageMagick-6.3.2,编译时有这样的错误:
gcc -c -I../ -I.. -I/usr/include/freetype2 -I/X11 -I/usr/include/libxml2 -D_REENTRANT - D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE - D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -g -O2 -Wall -W -pthread -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DVERSION=\"6.3.2\" -DXS_VERSION=\"6.3.2\" -fPIC "-I/usr/lib/perl5/5.8.5/i386- linux-thread-multi/CORE" -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c cc1: invalid option `tune=pentium4' make[1]: *** [Magick.o] Error 1
google了一下,大概发现是gcc版本的问题。
这台机器安装了Oracle 10g,安装前有一些compat版gcc是需要安装的:
compat-libgcc-296-2.96-132.7.2 compat-gcc-32-c++-3.2.3-47.3 compat-gcc-32-3.2.3-47.3
是不是这些补丁引起gcc不符合要求呢?
对比一下这台机器和其他没有安装oracle的机器(即没有安装gcc compat补丁)的gcc和g++版本信息:
安装了Oracle的机器:
$ gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++ --disable-libgcj --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47.3) $ g++ -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++ --disable-libgcj --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47.3)
没有安装Oracle的机器:
$ gcc -v Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info -- enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) $ g++ -v Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info -- enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
应该有多个gcc,我们来找一找:
$ which gcc /usr/bin/gcc $ cd /usr/bin $ ls gcc* gcc gcc32 gcc.orig
有三个,gcc32应该是3.2版的,我们来看下gcc.orig的信息:
$ gcc.orig -v Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
OK!符合!应该就是它了!
再来看看g++ :
$ ls g++* g++ g++32 g++.orig $ g++.orig -v Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
OK!都找到了!
把原来的gcc和g++备份一下,拷贝 gcc.orig 和 g++.orig 为gcc/g++ ,重新编译,成功!````










Anonymous # 19. August 2009, 23:00
Great, thanks a lot.