C++ dynamically linked libraries and dlopen

bridged with qnx.rtos
Post Reply
Johan Björk

C++ dynamically linked libraries and dlopen

Post by Johan Björk » Thu Feb 05, 2004 8:20 am

Hi everyone

When opening a .so (C++) with dlopen using the parameters

int main() {
a = dlopen(bleh.so,RTLD_NOW|RTLD_GLOBAL);
dlclose(a);
printf("We are lucky\n");
}
it opens and closes fine.

However, if I specify
RTLD_NOW|RTLD_LOCAL

It crashes in dlclose!!

The backtrace is a bit different depending if I use dinkum or gnustdc++.
using dinkum the backtrace is something like this (Sorry, doing this at
another computer)
_dlclose,_fini,_btext,"global destructors keyed to
std::ios_base::Init::_Init_cnt", 0xXXXX

Anyone know what might be causing this?
The dll is a plugin for the MMedia Framework so changing the dlopen is not
possible..

Any ideas is appriciated!

/Johan Björk

Chris McKillop

Re: C++ dynamically linked libraries and dlopen

Post by Chris McKillop » Thu Feb 05, 2004 4:52 pm

The backtrace is a bit different depending if I use dinkum or gnustdc++.
using dinkum the backtrace is something like this (Sorry, doing this at
another computer)
_dlclose,_fini,_btext,"global destructors keyed to
std::ios_base::Init::_Init_cnt", 0xXXXX

Anyone know what might be causing this?
The dll is a plugin for the MMedia Framework so changing the dlopen is not
possible..
Yeah, it has to do with when the shlib's get unopened. Basically you cannot
dlopen() a shlib that needs C++ in a main process that doesn't also need
C++. You can work around it with LD_PRELOAD. This should be fixed in 6.3.0,
although I have no tested it recently.

chris

--
Chris McKillop <cdm@qnx.com> "The faster I go, the behinder I get."
Software Engineer, QSSL -- Lewis Carroll --
http://qnx.wox.org/

Johan Björk

Re: C++ dynamically linked libraries and dlopen

Post by Johan Björk » Thu Feb 05, 2004 5:40 pm

Excellent!
That'll work just fine for now :)

/Johan

"Chris McKillop" <cdm@qnx.com> skrev i meddelandet
news:bvtsc9$aro$3@inn.qnx.com...
The backtrace is a bit different depending if I use dinkum or gnustdc++.
using dinkum the backtrace is something like this (Sorry, doing this at
another computer)
_dlclose,_fini,_btext,"global destructors keyed to
std::ios_base::Init::_Init_cnt", 0xXXXX

Anyone know what might be causing this?
The dll is a plugin for the MMedia Framework so changing the dlopen is
not
possible..


Yeah, it has to do with when the shlib's get unopened. Basically you
cannot
dlopen() a shlib that needs C++ in a main process that doesn't also need
C++. You can work around it with LD_PRELOAD. This should be fixed in
6.3.0,
although I have no tested it recently.

chris

--
Chris McKillop <cdm@qnx.com> "The faster I go, the behinder I get."
Software Engineer, QSSL -- Lewis Carroll --
http://qnx.wox.org/

Post Reply

Return to “qnx.rtos”