How to link in static objects from a static library?



Hi,

I am creating a static library (using "ar -cq ...") from a bunch of .o
files that all contain static "registrar" objects in certain classes.
In particular, I have a templated Registrar class, and each of the
classes being archived has a static member of type
Registrar<class_name> that is supposed to "register" a constructor
object for that class. When I explicitly list for the linker all of the
..o files that I am archiving, these Registrar objects are all
automatically linked into the executable such that they are all
constructed before main is called when I run the program. However, if I
instead try to link against an archive/static library of these very
same .o files, these Registrar objects are NOT being linked into the
executable.

I am wondering if there is a flag or something that I need to use in
order to force the linker to link in all static objects from the static
library in question? Or is this not possible to do? Any help would be
greatly appreciated. Thanks!

Matt

Here are trimmed down versions of the commands I am running (all of
these commands run w/o errors, save the static object issue mentioned
above):

Archive command:
ar -cq libs/libMyArchive.a
obj/rel/Uberserver/Credit/DO/TestFramework/DOThroughputTest.o
obj/rel/Uberserver/Credit/DO/TestFramework/DOCircularityTest.o
obj/rel/Uberserver/Credit/DO/TestFramework/DOLatencyTest.o
obj/rel/Uberserver/Credit/DO/TestFramework/DOIONodeFiller.o [more .o
files]

Link command that explicitly lists .o files (and WORKS):
g++ -g -L/creditdev/packages/pgsql/lib
-L/creditdev/packages/emgtools/lib-g++-3.4.3 -rdynamic
obj/rel/Base/StringUtilities.o obj/rel/Base/DebugUtils.o
obj/rel/Base/ConsoleUtilities.o obj/rel/Base/Time.o
obj/rel/Uberserver/Credit/DO/TestFramework/DOThroughputTest.o
obj/rel/Uberserver/Credit/DO/TestFramework/DOCircularityTest.o
obj/rel/Uberserver/Credit/DO/TestFramework/DOLatencyTest.o
obj/rel/Uberserver/Credit/DO/TestFramework/DOIONodeFiller.o [more .o
files] --start-group /creditdev/shared_libraries/libstdc++.so.6
/usr/local/ssl/lib/libcrypto.a -lEmgToolsSystemUtils -ltds -lpthread
-lncurses -ldl -lpq --end-group -o rel/slave

Link command that links against .a file (and does NOT work):
g++ -g -L/creditdev/packages/pgsql/lib
-L/creditdev/packages/emgtools/lib-g++-3.4.3 -rdynamic
obj/rel/Base/StringUtilities.o obj/rel/Base/DebugUtils.o
obj/rel/Base/ConsoleUtilities.o obj/rel/Base/Time.o [more .o files]
--start-group libs/libMyArchive.a
/creditdev/shared_libraries/libstdc++.so.6
/usr/local/ssl/lib/libcrypto.a -lEmgToolsSystemUtils -ltds -lpthread
-lncurses -ldl -lpq --end-group -o rel/slave

.



Relevant Pages

  • mail archiving stops working
    ... emacs 21.4.1, rmail) and in doing so, discovered that a command in my ... ~./emacs file stopped working. ... my outgoing messages are no longer being archived to ... but what command actually causes archiving ...
    (comp.emacs)
  • Re: Overwieght Database
    ... >> archiving out messages older than a certain number of days, ... >> allowing the command to delete messages after export. ... through the subfolders to find the data in standard .eml, .ics, .vcs data ... Microsoft MVP Seen the All-New Entourage Help Pages? ...
    (microsoft.public.mac.office.entourage)
  • Re: archive mailbox trough command line?
    ... Is there a way to make the Outlook archives the mailbox via command ... allowing the tech support to do the archiving for them. ... Outlook to archive the mailboxes via command line or a script that can ...
    (microsoft.public.exchange.admin)
  • TransferSpreadsheet code with date?
    ... I have placed a command button on a form for archiving ... data that exports to the user's hard drive. ... DoCmd.TransferSpreadsheet acExport, ...
    (microsoft.public.access.externaldata)