作者zxvc (zxvc)
看板LinuxDev
标题Re: gcc link的问题
时间Fri Mar 16 10:36:24 2007
: --
:
※ 发信站: 批踢踢实业坊(ptt.cc)
: ◆ From: 140.115.200.121
: 推 andytzeng:gcc 编译可以指定 version, name 03/16 09:56
: → andytzeng:http://blog.twpug.org/category/30/88 参考一下 03/16 09:57
我其实在man ldconfig时也查出一些蛛丝马迹.
man ldconfig:
ldconfig checks the header and file names of the libraries it
encounters when determining which versions should have their links updated.
然後我
$ strings libgtk-x11-2.0.so.0.1000.10 |grep libgtk-x11-2.0.so.0
果然有libgtk-x11-2.0.so.0
然後去google搜到这一篇:
http://sources.redhat.com/ml/libc-alpha/2004-09/msg00139.html
後来man ld发现这一段:
-soname=name
When creating an ELF shared object, set the internal DT_SONAME
field to the specified name. When an executable
is linked with a shared object which has a DT_SONAME field, then
when the executable is run the dynamic linker
will attempt to load the shared object specified by the DT_SONAME
field rather than the using the file name given to the linker.
所以我原来的问题要这样解决:
$ gcc h.c -c
$ ld h.o -o libh.so.0 -shared -fPIC
-soname libh.so.0
$ ln -s libh.so.0 libh.so
$ gcc test.c -o test -L. -lh
$ ldd test
(还是感谢andytzeng帮忙.)
--
Albert Einstein :
If there is any religion that could cope with modern scientific needs it
would be Buddhism.
《金刚经》离一切诸相,则名诸佛。
http://web.cc.ncu.edu.tw/~93501025/jg.doc
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.200.121
1F:推 andytzeng:您客气了...这是您的努力结果...:) 03/16 10:48