Staticly linked libraries not running code inside to setup static variables.
        Posted  
        
            by MJD
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by MJD
        
        
        
        Published on 2010-06-17T20:20:25Z
        Indexed on 
            2010/06/17
            20:23 UTC
        
        
        Read the original article
        Hit count: 217
        
In a c++ project I am working on, I have a simple c++ file that needs to run some code at the beginning of the progam execution. This file is linked into a static library, which is then linked into the main program.
I have similar code in other files running fine, that looks something like:
bool ____nonexistant_value = executeAction();
However, it does not work inside this file unless I make use of a function implemented in this file. It does work if the library is compilied as a shared library. I'd prefer to link this statically as the library is only a convience as the file is in a different directory.
© Stack Overflow or respective owner