日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux如何生成so文件,新人问个问题,莫见笑:关于如何生成so文件,大家多多捧场啊...

發布時間:2024/8/5 linux 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux如何生成so文件,新人问个问题,莫见笑:关于如何生成so文件,大家多多捧场啊... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

kilisky 于 2008-05-26 12:29:18發表:

你沒有安裝庫,當然看不到.so了,安裝了才可以看的到的。

make DESTDIR=安裝目錄 install

進入安裝目錄里看lib,就有了.

黃富強 于 2008-05-14 18:24:13發表:

才明白你的意思,研究一下這里面的

http://www.gnu.org/software/libtool/manual/automake/Hello-World.html#Hello-World

http://www.gnu.org/software/libtool/manual/html_node/index.html

fuqiang@fuqiang-laptop:~$ libtool --help

Usage: libtool [OPTION]... [MODE-ARG]...

Provide generalized library-building support services.

--config show all configuration variables

--debug enable verbose shell tracing

-n, --dry-run display commands without modifying any files

--features display basic configuration information and exit

--finish same as `--mode=finish'

--help display this help message and exit

--mode=MODE use operation mode MODE [default=inferred from MODE-ARGS]

--quiet same as `--silent'

--silent don't print informational messages

--tag=TAG use configuration variables from tag TAG

--version print version information

MODE must be one of the following:

clean remove files from the build directory

compile compile a source file into a libtool object

execute automatically set library path, then run a program

finish complete the installation of libtool libraries

install install libraries or executables

link create a library or an executable

uninstall remove libraries from an installed directory

MODE-ARGS vary depending on the MODE. Try `libtool --help --mode=MODE' for

a more detailed description of MODE.

Report bugs to .

.o : 編譯的目標文件

.a : 靜態庫,其實就是把若干o文件打了個包

.so : 動態鏈接庫(共享庫)

.lo : 使用libtool編譯出的目標文件,其實就是在o文件中添加了一些信息

.la : 使用libtool編譯出的庫文件,其實是個文本文件,記錄同名動態庫和靜態庫的相關信息

la只有在用libtool編譯應用程序或庫時才用,即開發者只指明la文件,至于最終鏈接a還是so由libtool決定,不使用libtool的小程序用不上la, so是直接用特殊編譯參數編譯出來的,注意路徑的問題.

其它實現方法:http://linux.chinaunix.net/bbs/thread-959710-1-1.html

[本帖最后由 黃富強 于 2008-5-14 19:28 編輯]

muyizhu 于 2008-05-14 14:19:04發表:

自己頂一下

muyizhu 于 2008-05-14 13:28:11發表:

謝謝強哥了

muyizhu 于 2008-05-14 13:26:48發表:

還是不行啊,參考的價值不大

我這邊文件可能會很多,所以最好是用libtool

那以下是我的過程:(假設只有一個文件add.c放在test文件夾下,想生成一個libtest.so)

**********add.c********************

#include "stdlib.h"

int add(int num1,int num2)

{

return (int)(num1+num2);

}

************************************

1. 進入到test下執行autoscan生成configure.scan,改文件名為configure.in,并作適當修改

2.執行aclocal生成aclocal.m4

3.執行autoheader

4. 編寫Makefile.am(使用libtool)

**************Makefile.am**************

AUTOMAKE_OPTIONS = foreign

lib_LTLIBRARIES = libtest.la

libtest_la_SOURCES = add.c

*****************************************

5.執行automake --add-missing

6. autoconf

7. ./configure

8. make

上面就是一般自動生成makefile的過程

我看網上有些人就是這么介紹通過libtool生成libtest.so的

可我make之后libtest.la是生成了,就是沒找到libtest.so這個文件

我想問的是怎么生成libtest.so

是不是makefile.am還需要做什么修改

muyizhu 于 2008-05-14 12:32:47發表:

又或者不用libtool

這個makefile.am需要怎么寫

muyizhu 于 2008-05-14 12:31:32發表:

我看網上有介紹到用libtool

結果libtest.la是生成了,但是libtest.so沒有生成

是不是這個makefile.am需要做什么修改

muyizhu 于 2008-05-14 12:29:15發表:

謝謝指教

可是直接用GCC我也知道怎么用

問題是我想自動生成makefile

自動生成過程中的makefile.am我不知道怎么寫

黃富強 于 2008-05-14 12:06:14發表:

gcc a.c b.c c.c -fPIC -shared -o libtest.so

動態鏈接庫相當于Windows中用的DLL

研究一下基本GCC使用方法,sou一下,很多.

[本帖最后由 黃富強 于 2008-5-14 12:10 編輯]

總結

以上是生活随笔為你收集整理的linux如何生成so文件,新人问个问题,莫见笑:关于如何生成so文件,大家多多捧场啊...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。