shared libs runtime link

Hi,
A main program built with -Wl,-E because I need it contains an
initResmgr function.
A shared lib I wrote also contains an initResmgr function.
This lib, in its init() function calls a pthread_create(NULL, NULL,
initResmgr, NULL);

When my main program dlopen() this lib and execute the init() function
of my lib, the pthread_create(NULL, NULL, initResmgr, NULL) start a
thread running the MAIN initResmgr instead of the one of the shared lib.

Why?

Thanks,
Alain.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

Hi,
A main program built with -Wl,-E because I need it contains an
initResmgr function.
A shared lib I wrote also contains an initResmgr function.
This lib, in its init() function calls a pthread_create(NULL, NULL,
initResmgr, NULL);

When my main program dlopen() this lib and execute the init() function
of my lib, the pthread_create(NULL, NULL, initResmgr, NULL) start a
thread running the MAIN initResmgr instead of the one of the shared lib.

Because we the symbols for the shared object are resolved, they
are resolved against the executable first.

If you want the shared object to only resolve against itself, then
use -Bsymbolic when linking it.

Why?

Thanks,
Alain.


cburgess@qnx.com

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

Hi,
A main program built with -Wl,-E because I need it contains an
initResmgr function.
A shared lib I wrote also contains an initResmgr function.
This lib, in its init() function calls a pthread_create(NULL, NULL,
initResmgr, NULL);

When my main program dlopen() this lib and execute the init() function
of my lib, the pthread_create(NULL, NULL, initResmgr, NULL) start a
thread running the MAIN initResmgr instead of the one of the shared lib.

When you dlopen() you shared object, you must use dlsym() to get ptrs to
symbols in that lib. Are you using dlsym()?

-Adam