2010-01-25 34 views
1

我嘗試創建一個共享庫,它在內部鏈接到許多共享庫和一個靜態庫。在我的情況下,我的共享庫不包括靜態庫。我想知道我在嘗試是否正確,或者我需要將靜態庫轉換爲共享庫,然後進行鏈接。我可以創建一個共享庫,它既有共享庫也有靜態庫

我需要知道是否有任何makefile標誌允許我將靜態庫與共享庫一起添加。

請建議。

+0

你的帖子的標誌需要更具體的(庫...) – Phong 2010-01-25 11:44:33

+0

你需要告訴我們你是如何進行鏈接。 – 2010-01-25 11:45:17

+0

甚至有沒有可能不包含靜態庫的鏈接方式? – Murali 2010-01-25 11:47:54

回答

0

您可以創建一個依賴於其他庫(靜態和動態)的庫。但是,你需要靜態庫部分整合你的(因爲這一個不能被動態加載)

dependence of your source code: 
your_library -> static_library.lib 
your_library -> dynamic_library.dll 

how you implement can it (to be used by an executable): 

your_library.dll (which contain your_library and static_library source code) 
dynamic_library.dll (to distribute with your_library.dll) 

or 

your_library.dll 
static_library.dll (to be created from the static_library.lib) 
dynamic_library.dll (to distribute with your_library.dll) 

編輯內:這裏可能是你正在尋找convert static library to shared library(它是Linux,但你也會有同樣對於OS):

.a files are just archives of .o object files, so all you need to do is unpack the archive and repackage them as a shared object (.so) 
ar -x mylib.a 
gcc -shared *.o -o mylib.so