Static member variables and static libraries

P

Paul

Hi,

I am very grateful to all reading this message.I wish to know if anyone
could help me: I´ve got a problem while creating an application using a
static library.

Problem:
I created a pluggable factory class in one of my projects but the self
registering mechanism depends on
the inicialization of a static member variable.
I tried to put my factory class in a static library, but doing so I
discovered the static variables weren´t
initiated before the execution of Winmain.

Question:
Is there anyway to force the incialization of static member variables of
static libraries to happen before the
execution of Winmain? (using MS compilers and/or any other)
A workaround solution could also be acceptable if it doesn´t require to
create instances of the objects containing
the static member variables. It´s also important to the solution not to need
adding new code to the application using
the static library.

Thank you all, Paul.
 
C

Carl Daniel [VC++ MVP]

Paul said:
Hi,

I am very grateful to all reading this message.I wish to know if
anyone could help me: I´ve got a problem while creating an
application using a static library.

Problem:
I created a pluggable factory class in one of my projects but the
self registering mechanism depends on
the inicialization of a static member variable.
I tried to put my factory class in a static library, but doing so
I discovered the static variables weren´t
initiated before the execution of Winmain.

Question:
Is there anyway to force the incialization of static member
variables of static libraries to happen before the
execution of Winmain? (using MS compilers and/or any other)
A workaround solution could also be acceptable if it doesn´t
require to create instances of the objects containing
the static member variables. It´s also important to the solution not
to need adding new code to the application using
the static library.

This is a frequent question. Google this group for "#pragma comment(linker"
and you should find a number of solutions.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top