2010-01-25 75 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