Re: gcc link的問題
: --
: ※ 發信站: 批踢踢實業坊(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
推
03/16 10:48, , 1F
03/16 10:48, 1F
討論串 (同標題文章)
LinuxDev 近期熱門文章
PTT數位生活區 即時熱門文章