Post by R***@ptt.cc在書中看到一段話:linux 的共享函式庫是在執行時期以動態方式連結的
可以讓程式設計師以自已的函式來取代標準函式庫所提供的模組。
以上這段話是代表什麼意思呢???
此外若有靜態和動態兩個函式庫同時存在,這時程式是要使用靜態函式庫還是動態函式庫??
除了靜態函式庫會在編譯時加入程式之外,就沒有什麼不好之處,那這兩種的函式庫的使用
時機大多是什麼情形下才會特定的使用呢??
謝謝~~~~
Execuse me for the reply in English. My English typing is much faster than my T-Chinese one.
First try "man ld" for the loader information.
You need to know, normally we don't directly call "ld". It is normally called by your compiler(for example gcc).
-Bstatic to specify to link the system library into your executing program.
-Bdynamic to specify to use dynamic library when you run your executing program. This is the default.
Normally:
- static has bigger executing image. And since it loads all of the programs into the system memorywhen the program first begin executing, it will be a little faster if your program is large enough.
- if you move your executing code from one machine to another, while these two systems are different distribution of Linux, you may experience some problem to run your codes on 2nd system if you use dynamic link. For the system library may be located or even totally different between these two systems.
How about just write a simple "HELLO WORLD!" C program to test it.
You can pass "-static", or "-shared" options to the gcc compiler, to see what's the difference.
Use "man gcc" for more gcc options.
Regards,
--
好康訊息!
Openfind 提供免費撥接電話:40508888
帳號:openfind 密碼:openfind
--
http://bbs.openfind.com.tw
※來源:221.249.*