From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel.Walker@lhsl.com To: gcc-help@gcc.gnu.org Subject: -l versus dlopen() Date: Fri, 07 Sep 2001 10:41:00 -0000 Message-id: X-SW-Source: 2001-09/msg00025.html Hello, 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. Thanks Daniel Walker