Let's say I have a C++ library code, with some definitions wrapped with extern "C" { ... }.
I also have a C library code which uses that C++ library.
What I want to do is to create a single .so file, so that only one call to dlopen should be enough to start using this library.
Here's what I do now: I'm first compiling my C++ library to a .so file with -shared -rdynamic -fPIC. Then I'm compiling my C library to a .so file with same parameters. After that, I have to load C++ library with dload before loading the C library. Otherwise loading fails with a undefined symbol error.
What I want to do is to compile this two libraries into one .so file so that only one call to dload should be enough to use it.
How can I do that?
Thanks in advance.
EDIT: Compiling to .o files and then combining doesn't work for me. Here's what I do:
- I compile each file to object file with -fPIC parameter
- I link them with
clang [list of object files] -shared -rdynamic -fPIC -o libmylib.so - When I try to load, I get
undefined symbol: __gxx_personality_v0error.
EDIT2: Ahh, I forgoto to link it against libstdc++, it works now. Thanks.