h*****w 发帖数: 220 | 1 最近接手一个以前的学生写的程序,编译时需要用到一些库,
g++命令片段如下
g++ -L/usr/lib -lcurses -lX11 -lXmu -lXi -lGL -lGLU -lglut
对应的库是
libcurses.so libX11.so libXmu.so libXi.so libGL.so libGLU.so libglut.so和
libglut.a(不知道实际上会用哪个?)
在实验室机器上Fedora 9,能够正常编译和运行
我做了如下尝试,全部能够正常编译,但是运行起来总出现segment fault,要不就是
死机,唯一例外的就是在学校提供的系统RHEL6上,可以正常运行。目前还没有尝试查
看源代码,因为我认为既然在某个环境中能正常运行,那么代码不应该有相关问题。
尝试一
在Fedora 15(F9已经不更新了)上安装上述库,运行能够出现GUI界面,但是进行操作
(按一些命令键,在实验室F9的环境里会出问题)就segment fault或死机, 也试过
gdb,run完GUI出现,continue就出错,显示是corrupted double linked list
尝试二
在Ubuntu 10.04和11.04下,安装了上述库,运行能够出现GUI界面,但是进行操作就出
错,shell显示的信息是malloc函数出错
尝试三
在red hat enterprise linux 6上安装了上述库,正常运行,但是有时也会出现
segment fault。考虑到可能是库的版本问题,在RHEL6下把这些库(确认了不是soft
link)都复制到ubuntu下,重新编译运行,问题依旧。
有人知道可能是哪里的问题吗?
另外我对程序编译运行的理解如下,不知有什么错误没有?谢谢
当动态编译时,compiler会在binaries里面嵌入shared library的目录,在运行时会从
这些目录load相应的library。 |
l*******G 发帖数: 1191 | 2 just some speculations:
the libraries
libcurses.so libX11.so libXmu.so libXi.so libGL.so libGLU.so libglut.so
libglut.a
you have on your computer may have multiple versions. So different parts of
your code may be linked to different versions of the libs.
Make sure for each lib, you just consistently use the same version. Check
your LD_LIBRARY_PATH, (help http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html)
Some of the libs above may be soft or hard links to some files in your file
system. Make sure the links do not go in circles.
Other than that, the .so files are normally for shared library when doing
the linking step in generating the executable, and .a files are for the
static linking instead. So you may try to use the .a files instead of the .
so files by turning off the compiler options that specify shared-lib-linking
, for gcc, the option is -shared -fPIC vs -static
where -fPIC is particularly interesting, again read http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html |
r****t 发帖数: 10904 | 3 可能是库/gcc版本问题,用的库版本和 gcc 版本文档里面有说么。
以后要求你的学生用 autotools。
【在 h*****w 的大作中提到】 : 最近接手一个以前的学生写的程序,编译时需要用到一些库, : g++命令片段如下 : g++ -L/usr/lib -lcurses -lX11 -lXmu -lXi -lGL -lGLU -lglut : 对应的库是 : libcurses.so libX11.so libXmu.so libXi.so libGL.so libGLU.so libglut.so和 : libglut.a(不知道实际上会用哪个?) : 在实验室机器上Fedora 9,能够正常编译和运行 : 我做了如下尝试,全部能够正常编译,但是运行起来总出现segment fault,要不就是 : 死机,唯一例外的就是在学校提供的系统RHEL6上,可以正常运行。目前还没有尝试查 : 看源代码,因为我认为既然在某个环境中能正常运行,那么代码不应该有相关问题。
|
A*g 发帖数: 102 | 4 try CDE
http://www.stanford.edu/~pgbovine/cde.html
【在 h*****w 的大作中提到】 : 最近接手一个以前的学生写的程序,编译时需要用到一些库, : g++命令片段如下 : g++ -L/usr/lib -lcurses -lX11 -lXmu -lXi -lGL -lGLU -lglut : 对应的库是 : libcurses.so libX11.so libXmu.so libXi.so libGL.so libGLU.so libglut.so和 : libglut.a(不知道实际上会用哪个?) : 在实验室机器上Fedora 9,能够正常编译和运行 : 我做了如下尝试,全部能够正常编译,但是运行起来总出现segment fault,要不就是 : 死机,唯一例外的就是在学校提供的系统RHEL6上,可以正常运行。目前还没有尝试查 : 看源代码,因为我认为既然在某个环境中能正常运行,那么代码不应该有相关问题。
|
h*****w 发帖数: 220 | 5 thanks, the given link is very useful.
of
file
【在 l*******G 的大作中提到】 : just some speculations: : the libraries : libcurses.so libX11.so libXmu.so libXi.so libGL.so libGLU.so libglut.so : libglut.a : you have on your computer may have multiple versions. So different parts of : your code may be linked to different versions of the libs. : Make sure for each lib, you just consistently use the same version. Check : your LD_LIBRARY_PATH, (help http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html) : Some of the libs above may be soft or hard links to some files in your file : system. Make sure the links do not go in circles.
|
h*****w 发帖数: 220 | 6 哈哈,我还是个学生,光关注库的版本了,这个gcc的版本倒是忽略了。linux下版本兼
容问题令人头痛啊
【在 r****t 的大作中提到】 : 可能是库/gcc版本问题,用的库版本和 gcc 版本文档里面有说么。 : 以后要求你的学生用 autotools。
|
l*****u 发帖数: 12114 | 7 吓一跳,以为CDE做为WM又满血复活了。。。。
就是
试查
【在 A*g 的大作中提到】 : try CDE : http://www.stanford.edu/~pgbovine/cde.html
|