initialization of dlopen()ed dlls

Hello,

how do I initialize a dll loaded with dlopen?
Usualy I would us a pragma like this:

#pragma init(my_init)
static void my_init(void)
{ … }

to get the function into the .init section but I only get the warning
‘pragma ignored’. Is it somehow possible to get an initializing function
running when loading the dll?

  • Wolfram

Wolfram Manthey <qnxnews@arcor.de> wrote:

Hello,

how do I initialize a dll loaded with dlopen?
Usualy I would us a pragma like this:

#pragma init(my_init)
static void my_init(void)
{ … }

to get the function into the .init section but I only get the warning
‘pragma ignored’. Is it somehow possible to get an initializing function
running when loading the dll?

Try the gcc ‘constructor’ attribute.
http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/Function-Attributes.html#Function-Attributes

-seanb