如何链接共享库对其他共享库在linux? [英] how to link shared library against other shared library in linux?

查看:115
本文介绍了如何链接共享库对其他共享库在linux?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程式动态载入 liba.so (含 dlopen )。

liba.so 使用 libb.so ,因此我想链接 liba.so libb.so
在Linux中如何做到这一点?

My application dynamically loads liba.so (with dlopen).
liba.so uses libb.so so I want to link liba.so against libb.so. How to do this in Linux?

提前感谢。

推荐答案

$ c> liba.so 您需要链接 -l <​​/ code>选项

If you build liba.so yourself, you need to link it with -l option

gcc -o liba.so liba.o -L/libb/path -lb

如果你没有 liba 源,也许你可以创建 libawrapper.so linked对 liba libb 并动态加载此库

If you don't have liba sources, perhaps you could create libawrapper.so linked against liba and libb and to load dynamically this library

gcc -o libawrap.so -L/liba/ -L/libb/ -la -lb

这篇关于如何链接共享库对其他共享库在linux?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆