Hi, I have a global object instantiated in a source file. Depending on how the resulting object file is linked, that global object is successfully created or not. It appears that gcc quite sensibly doesn't link in symbols that aren't used. I'm attaching an example showing off my question. The executable is built two ways. In the first way, it is build via a static library to which the final executable is linked. In the second way, the object files are just all compiled together skipping the library. There is a global object (in global_object.cc) which I want to get created before main() starts and it does not work if I build the executable by linking against the static library. I'm trying to create a little system where some of my software components can register themselves automatically, so to work they way I want it to I am not really free to re-arrange the source. If anybody has any insight into how to make this work, I'd appreciate it. is there some linker flag to get these unreferenced global objects created? Thanks, John
Attachment:
global-object.tgz
Description: GNU Zip compressed data