如何将共享库与Linux中的其他共享库链接?

时间:2023-02-13 10:27:48

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?

我的应用程序动态加载liba.so(使用dlopen)。 liba.so使用libb.so所以我想将liba.so链接到libb.so.如何在Linux中执行此操作?

Thanks in advance.

提前致谢。

1 个解决方案

#1


6  

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

如果您自己构建liba.so,则需要将其与-l选项链接

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

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

如果你没有liba源代码,也许你可以创建libawrapper.so链接liba和libb并动态加载这个库

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

#1


6  

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

如果您自己构建liba.so,则需要将其与-l选项链接

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

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

如果你没有liba源代码,也许你可以创建libawrapper.so链接liba和libb并动态加载这个库

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