Red Alert
Red Alert

Reputation: 3816

Is it possible to use gcc's linker in conjunction with dlopen?

So, I have a program that makes use of the xerces-c c++ library. I am trying to modify it to not require the library be present when the program is run, since there are parts of it that can be run independently. Is is possible to accomplish this using dlopen() to load the library, while still using the linker in gcc to resolve symbols at compile time? Maybe I'm missing something but the xerces-c API seems very difficult to use with dlsym(), which is why I am trying to find a workaround.

Upvotes: 0

Views: 88

Answers (1)

nneonneo
nneonneo

Reputation: 179382

The easiest solution in cases like this would be to split your program into two parts, a main program that doesn't have a xerces-c dependency, and a shared library that does. Then you dlopen your shared library, which loads xerces and uses it. In this way you can define your own library API, basically.

Upvotes: 3

Related Questions