Question

I am writing a library that is loaded dynamically by another progam. This library uses some Boost libraries (for example, thread). Is it possible to make it work somehow without recompiling the program in question?

If I use the link flags -lboost_thread, it doesn't work, because the program that uses this library would need to link the same Boost library, too. Using /usr/lib/libboost_thread.a also doesn't work, because the .a file isn't compiled with -fPIC.

I am using GCC under Linux.

Était-ce utile?

La solution

Trying again, I found that the problem was not what I described. The library didn't load for some other reason. I found that linking the library with -lboost_thread works, with the following conditions:

  • gcc gives compiler warnings (possibly because the libraries are from the -L path which is not in $LD_LIBRARY_PATH).
  • When loading the library, it loads Boost automatically provided it can find them.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top