开发者

Shared library, library dependancy

开发者 https://www.devze.com 2023-03-19 02:41 出处:网络
Is it possible to provide a shar开发者_JAVA百科ed library - which links against another shared library during its creation - transparent to the end user?

Is it possible to provide a shar开发者_JAVA百科ed library - which links against another shared library during its creation - transparent to the end user?

As an example of what I mean:

Shared Library Build

g++ ... `pkg-config gtk+-2.0 --cflags` ... `pkg-config gtk+-2.0 --libs`

Desired User Build

g++ file.cc -lfoo

Where libfoo.so.0 is the shared library.

I can only seem to get this to work if the user build includes the pkg-config gtk+-2.0 .... Is there a way, during the creation of the shared object, to allow the end user to not have to worry about the indirect libraries used within libfoo?


If you have a shared library libABC.so which links to libXYZ.so then,
while creating your libABC.so, you have to link with libXYZ.so

 ld --shared -o libABC.so -L. -lXYZ

While compiling the application,

gcc app.c -L. -lABC

don't forget to, export the library path

export LD_LIBRARY_PATH=.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号