我可以创建一个包含共享库和静态库的共享库

时间:2010-01-25 11:34:19

标签: makefile shared-libraries static-libraries

我正在尝试创建一个内部链接到许多共享库和静态库的共享库。在我的情况下,我的共享库不包括静态库。我想知道我在尝试它是否正确或我需要将静态库转换为共享库,然后进行链接。

我需要知道是否有任何makefile标志允许我添加静态库和共享库。

请建议。

1 个答案:

答案 0 :(得分: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,但是对于操作系统也是如此):

.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