Shared object constructor not called when library loaded
OS Version: Linux red hat EL5
g++ version: 4.1.1 ld version: 2.17.50.0.6-2.el5 I have a shared library and a unit test executable that depends on the shared library. Both compile and link without warning or error. The g++ options for the shared library are: compile: -fPIC -Wall -Wno-unused-function -fno-strict-aliasing -g -O0 link: -shared -lstdc++ The options for the unit test executable are the same without the -shared. In the shared library I have designated a constructor function as so: Code:
#define ZENCORE_CONSTRUCTOR __attribute__ ((constructor)) #1 0x002a89b1 in global constructors keyed to _ZN3zen12g_UUIDRandomE() at zenuuiinitialize.cpp: 93 #2 0x002a8b46 in __do_global_ctors_aux() from /usr/local/lib/ngs/libzencored.so #3 0x00234c2d in _init() from /usr/local/lib/ngs/libzencored.so #4 0x00886f03 in call _init() from /lib/ld-linux.so.2 #5 0x00887013 in _dl_init_internal() from /lib/ld-linux.so.2 #6 0x0087984f in _dl_start_user() from /lib/ld-linux.so.2 I compiled a test program with a similar structure and with the same compile/link options and it worked just fine. Also, another shared library that the unit test executable depends on loads the construction function correctly. I am at a loss and appreciate any help or ideas. Cheers A |
I assume you're linking with ld because you use -lstdc++. You should link with g++ instead.
Kevin Barry |
I'm using g++ to link. The -lstdc++ had no effect as it functions (or doesn't) the same with and without it.
|
All times are GMT -5. The time now is 09:07 AM. |