日期:2014-05-16  浏览次数:20799 次

GCC跨版本编译的问题。浮点数例外
RT。我的一台虚拟机的gcc版本信息如下:

-bash-3.2$ gcc -v
使用内建 specs。
目标:i386-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
线程模型:posix
gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-48)
-bash-3.2$ ld -v
GNU ld version 2.17.50.0.6-14.el5 20061020
-bash-3.2$ 

在此虚拟机下,编译无问题,运行也正常。但是到了下面这台机,gcc版本信息为:

webp2@GA:~> gcc -v
Using built-in specs.
Target: i586-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.0 --enable-ssp --disable-libssp --enable-java-awt=gtk --enable-gtk-cairo --disable-libjava-multilib --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --without-system-libunwind --with-cpu=generic --host=i586-suse-linux
Thread model: posix
gcc version 4.1.0 (SUSE Linux)
webp2@GA:~> ld -v
GNU ld version 2.16.91.0.5 20051219 (SUSE Linux)


在这台机上面来编译无问题,一运行就报错:浮点数例外  
请问这个问题要怎么解决啊?也网上找过,有人说加编译选项“-Wl,--hash-style=sysv”,但是估计是后面这台机的ld版本太低,不能识别这个选项。请问这个问题要如何才能解决啊??(100分奉上)
gcc 版本?

------解决方案--------------------
检查一下你的程序会不会出现除数为0的情况;
加上-static试试;
如果不行,那就不知道了。。。
------解决方案--------------------
高版本的编译出的应用要运行到低版本是会经常出现这样的问题的。其实加上
Wl,--hash-style=sysv
也得不到什么改善。
很多原因是由于除数为0的情况,如果实在定位不到,就gdb进行跟踪吧。
------解决方案--------------------
不知道你的问题解决了没有?我特别写了篇文章,针对该问题的处理。
http://westsoftware.blog.163.com/blog/static/2609410920132294512298/
------解决方案--------------------
你应该更新一下GCC的版本