Re: global objects not initializing -- GCC 3.2.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Nick,

>I'm looking for the reason why global objects defined in statically-linked libraries are not initialized at run time.

Your global object named x is not used in main.cpp, so it is not being included (sort of like the opposite "dead code stripping" -- "live code inclusion"). And hence, is not being constructed.

To force all the symbols (and their corresponding objects) to be incorporated into your main.out from your archive regardless of use, change your compilation like this:

g++ -g -I. main.cpp -L. -Wl,--whole-archive -lTest -Wl,--no-whole-archive -o main.out

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux