From: Brendon C. <bc...@av...> - 2007-05-16 08:27:03
|
Hi all, Does ar in MinGW have any known problems with multiple invocations in order to add objects to an archive spread over a few command line invocations? I.e. ar cru blah.a obj1.o ar cru blah.a obj2.o In case the answer to the above is no, I will go through the details of the problem I am seeing. Our build system has just started invoking ar a number of times, as the number of objects being added into an archive has reached a limit where we need to perform the operation over multiple command line invocations. An example of what is going on is as follows: # Compile source to objects... g++ compiles heaps of code.... # We then run the ar command for the first batch of files... ar cru ./libs/libUtils.a ./libs/Timers/TimeStamp.o ...many-other-objects... # Then we run ar a second time to add the rest of the objects: ar cru ./libs/libUtils.a ./libs/System/Win32/TimeStamp.o ...many-other-objects... # Then we run ranlib on the archive: ranlib ./libs/libUtils.a In the above example i am showing two particular objects. Both are called: TimeStamp.o, but the one in the Win32 directory has windows specific code used to implement this time stamp, and the other has generic code common to all platforms to implement a time stamp class. I am not sure if this is allowed or not. I has been working in the past though and works fine on UNIX platforms where we are invoking ar only once still. When i link an application with the library: g++ -o app.exe main.o ./libs/libUtils.a ...other-link-flags... It complains with a lot of undefined symbol linking errors like: :C:/msys/1.0/home/Administrator/src/ADS/Utils/src/libs/Logging/ArchivingFileReporter.cpp:123: undefined reference to `ADS::Utils::Timers::TimeStamp::GetUTCTime()' Now, i ran nm over the archive just to see if one of the missing symbols was in it. For example searching for the GetUTCTime() member gives: nm -C ./libs/libUtils.a | grep TimeStamp::GetUTCTime 0000096c T ADS::System::System::TimeStamp::GetUTCTime() U ADS::Utils::Timers::TimeStamp::GetUTCTime() U ADS::Utils::Timers::TimeStamp::GetUTCTime() U ADS::Utils::Timers::TimeStamp::GetUTCTime() This is expected as the above will not show the various objects in the archive (filtered out by grep). One object defined the symbol in the code section, and others have it listed as undefined which i expect. Does anyone know why the link command failed to find the specified symbol that is in the archive? I suspect it has something to do with the order of the objects in the archive as if i touch the Utils/TimeStamp.cpp file and recompile etc the list of undefined symbols changes. The above TimeStamp is no longer undefined. Anyhow, thanks in advance for any information people might have to offer. Brendon. |