-l versus dlopen()

Daniel.Walker@lhsl.com Daniel.Walker@lhsl.com
Fri Sep 7 10:41:00 GMT 2001

I'm not sure if this is the right place to ask this question since it
probably has more to do with ld.so. If I'm in the wrong place maybe someone
can point me in the right direction.

I'm running Linux 2.4, gcc 3.0.

I have a C++ shared object, libfoo.so, compiled with -fPIC & -shared. If I
compile an executable with -lfoo, the library is loaded and everything is
fine. But if I link dynamically with dlopen() (compiled with -rdynamic),
the program crashes while executing a global constructor in
_do_global_ctors_aux(). Is it possible that the constructors in the library
are reorder differently depending on how the library is loaded? I've tried
it with several combinations of dlopen's flags and nothing seems to help.
I'm at a complete loss.

Daniel Walker

More information about the Gcc-help mailing list