This is a well-known issue with static libraries and global variables with runtime initialization.
Most linkers will only include the components of the static library needed to run the dependency on the main program. If none of the objects in the compilation unit are used, the linker deletes never adds the compilation unit as a whole, and side effects of global initialization do not occur.
There is a good explanation here (summary summary here )
You would have the same problem with the standard static code provided by the library.
Ben voigt
source share