Re: global objects in a static library not exported

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

 



Ian,

I'll give it a whirl.  It worked perfectly on my little test.

Thanks,

John

On Fri, Aug 28, 2009 at 8:07 AM, Ian Lance Taylor<iant@xxxxxxxxxx> wrote:
> John R Pretz <john.pretz@xxxxxxxxx> writes:
>
>> 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.
>
> This is standard Unix linker behaviour for archives.
>
>> 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?
>
> You use the --whole-archive option to direct the linker to pull in every
> object from an archive.  You would normally use --whole-archive around
> th archives you want to pull in entirely, ending with
> --no-whole-archive.
>
> Ian
>


[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