close

Linux .a / .so / .la 函式庫的差異

Linux *.a / .so / .la 在下述位置可以參考看看(Debian): (沒有在路徑內的應該是沒裝此 Library)

§  /usr/lib/x86_64-linux-gnu/ *.a, *.so

§  /usr/lib/x86_64-linux-gnu/ImageMagick-6.7.7/modules-Q16/coders/ *.la

§  /lib/modules/3.2.0-4-amd64/kernel/net/wireless/*.ko

Linux .a / .so / .la 函式庫的差異

下述參考自此篇: Linux .a / .so / .la 函式庫區別

§  .o (obj file) 是目標物件函式庫, 等同於 Windows .obj

§  .a 為靜態函式庫, 可以是 一個 多個 .o 合在一起, 用於靜態連結

§  .la libtool 生成的共享函式庫, 其實是個設定的檔案. 可以用 file 代替

§  .la 可用 vi 來查看

§  .so 為動態函式庫, 類似 Windows DLL(Dynamic-link library).

§  補充: 還有一種附檔名為 .ko 的檔案, 不過它是 Linux 核心使用的動態連結文件, 屬於模組程式, 用來在 Linux 系統啟動時, 加掛核心模組用.

.o, .a, .so, .la 如何產生

§  建立 .o
$ gcc -c test.c

§  建立 .a
$ ar -r libtest.a test1.o test2.o

§  建立動態函式庫 .so
$ gcc -Wall -fpic -shared test1.c test2.c -o libtest.so

§  鍊結函式庫
$ gcc -Wall -fpic -shared -Ltest test3.c -o libtest.so

§  建立 .la, .la 一般會使用 Makefile 產生, 可以透過下述命令產生:
$ libtool --mode=link gcc -o libmylib.la -rpath /usr/lib –L/usr/lib –la

 

 

 

Ref:

https://blog.longwin.com.tw/2013/03/linux-a-so-la-library-diff-2013/

 

________________________________________ 3S CONFIDENTIALITY NOTICE: This message and all attachments may contain legally privileged and confidential information. Any unauthorized review, use or distribution by anyone other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by replying to the message and delete all copies. Thank you.
arrow
arrow
    全站熱搜

    天才R 發表在 痞客邦 留言(0) 人氣()