Re: gcc link的問題

看板LinuxDev作者 (zxvc)時間18年前 (2007/03/16 10:36), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
: -- : ※ 發信站: 批踢踢實業坊(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
文章代碼(AID): #15-WAhiF (LinuxDev)
討論串 (同標題文章)
本文引述了以下文章的的內容:
1
2
18年前, 03/16
完整討論串 (本文為第 2 之 2 篇):
1
2
18年前, 03/16
1
1
文章代碼(AID): #15-WAhiF (LinuxDev)