Statically 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
21:13 UTC
Read the original article
Hit count: 146
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 program 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 ____nonexistent_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 compiled as a shared library. I'd prefer to link this statically as the library is only a convenience as the file is in a different directory.
© Stack Overflow or respective owner