我可以创建一个既有共享库又有静态库的共享库吗

发布于 2024-08-18 16:23:27 字数 165 浏览 2 评论 0原文

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

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

请建议。

I am tryng to create a shared library which internally is linking to many shared lib and a static lib . In my case my shared lib is not including static lib . I want to know what i am trying whether it is correct or i need to convert static lib to shared lib and then do the linking .

I need to know that is there any makefile flag which allow me to add static library along with shared lib .

Please suggest .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独自唱情﹋歌 2024-08-25 16:23:27

您可以创建一个依赖于其他库(静态和动态)的库。但是您需要将静态库部分集成到您的编辑中(因为这个无法动态加载)

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

You can create a library which is dependent of other library (static and dynamic). But you need to integrate the static library part inside your (because this one can not be load dynamically)

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)

edit: here may what you are looking for convert static library to shared library (it is for linux, but you will have the same for 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文