[CMake] Newbie question: Static linking

Hendrik Sattler post at hendrik-sattler.de
Sun May 22 19:53:57 EDT 2011


Am Montag, 23. Mai 2011, 01:36:14 schrieb Sanatan Rai:
> After cmake, and make all, the libraries build as static archives, ie I get
> liblib1.a, liblib2.a, libhelper1.a, libhelper2.a and executable myProj in
> the appropriate locations. However, the executable myProj does not appear
> to have linked statically to libhelper1.a and libhelper2.a. These
> libraries contain global initialisers for certain objects: which doesn't
> happen when I run the executable.

Most likely, the linker just drops those "global initialisers" when linking 
statically.  See the linker options in "man ld" to prevent that or give the 
library an initialisation method.

HS


More information about the CMake mailing list