c++/7769: using static libraries sometimes loses static initialization
bangerth@dealii.org
bangerth@dealii.org
Thu Dec 19 17:40:00 GMT 2002
Synopsis: using static libraries sometimes loses static initialization
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Thu Dec 19 17:40:05 2002
State-Changed-Why:
This is not a bug. When you want that a particular
object file (possibly within an archive) is pulled into you
executable for sure, then you have to reference an object
inside it.
If you rename your class "A" to "ComplexClass", to make
its symbols better visible in the executable, you
see that the object file with the static constructor
is not even pulled into the executable:
g/static_init> nm main1 | grep ComplexClass
080485f0 W __12ComplexClass
g/static_init> nm main2 | grep ComplexClass
g/static_init> nm main3 | grep ComplexClass
g/static_init> nm main4 | grep ComplexClass
080485f0 W __12ComplexClass
I guess this is just how the linker works.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7769
More information about the Gcc-prs
mailing list