Nick Ing-Simmons wrote:
Usual snag with C++ loadables is that dlopen() does not automatically
call constructors. So if your code or the library has static constructors
nothing initializes them.

I know this thread is over a year old, but I think I'm having just this problem. I'm trying to write an extension for a 3rd party library that was written in C++, and it crashes with dynamic linking (but works with static).


(a) Does anyone have a simple C++/XS example with static constructors so I can verify that this is the problem? My C++ knowledge is old and shaky, and my attempts were apparently so simple that the static initialization got optimized away (even with -O0).

(b) Is there a simple fix other than a completely static build? I tried building a new perl binary (as described in CookbookB/CCsimple) with the 3rd party library added to LIBS, but it didn't help.

For the record, this is Perl 5.8.6, running on HPUX 11.11, compiled and linked with g++-3.2.1.
--
John Breen

Reply via email to