The C runtime library contains some code that looks like this (sort of, it's probably a lot more complicated, and I'm sure the names aren't right - but I'm explaining the principle, not the actual implementation):
Code:
int __main(...)
{
int res;
run_global_constructors();
res = main(...);
run_global_destructors();
return res;
}
Of course, if you never link in the __main function, then you are not going to get the global constructors/destructors to run.
static objects are no different from global objects when it comes to construction/destruction - the only difference with static objects is which bits of code can see the variable representing the object.
--
Mats