2

我正在尝试创建一个共享库,该库在内部链接到许多共享库和一个静态库。就我而言,我的共享库不包括 static lib 。我想知道我在尝试什么是否正确,或者我需要将静态库转换为共享库然后进行链接。

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

请建议。

4

1 回答 1

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)

编辑:这可能是您正在寻找的将静态库转换为共享库(它适用于 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
于 2010-01-25T11:49:33.303 回答