Global variable construction in external libraries

I'm working on a library and I use global variables to initialize some things automatically. It's critical that the ctors for these global objects are run without having to be called explicitly by the program that is using the library.

The constructors of these global objects add a pointer to themselves to a global vector in their ctor. This way the vector can be polled to iterate through all of these global objects.

I have everything working peachy when I compile this library with my test program all as the same executable. However when I gave this lib to a friend to test it, he built it as an external library which he statically linked to his program (I believe he's on WinXP, using VS2008). When he did this, it became apparent that the ctors for these global objects were not running because the vector was empty when polled.

How can I ensure that all my global objects will be properly constructed when my code is built as an external library (statically or dynamically linked)? Is there a platform/compiler independent solution for this? I don't have a lot of experience with building libs.

Any help appreciated.
Topic archived. No new replies allowed.