From: Jack D. <jjd...@da...> - 2004-01-20 17:56:40
|
On Mon, 19 Jan 2004, Luke Dunstan wrote: > > ----- Original Message ----- > From: "Justin Forest" <vh...@us...> > To: <min...@li...> > Sent: Monday, January 19, 2004 4:47 AM > Subject: [Mingw-users] exporting symbols from an archive > > > > Hello. > > > > I'm building a dynamic library from several *.o and *.a files. > > Everything is normal except that symbols from *.a, even though they are > > definde as __declspec(dllexport), are not exported. The ones from *.o > > files are, as expected. > > > > However, if I add a non-exported function like: > > > > void dummy(void) > > { > > a_function_from_ar(/* args */); > > } > > > > Then the function is exported. Is there a way to tell the linker to > > export symbols from the archive, even if they are not referenced, > > without using such a trick? > > IMHO this is a bit outside the intended use of archives, so I am not > surprised that it doesn't work. Perhaps the linker options "--undefined" > and/or "--whole-archive" will help to achieve the same effect as your dummy > function. > > Luke --whole-archive works for me. One hint; it's a switch that applies to archives after it in the link command line and can/should be toggled off so you'll probably want something like: $ gcc -shared -o mycode.dll -Wl,--whole-archive mycode.a \ -Wl,--no-whole-archive otherarchive.a -lnetapi32 -lwsock32 The above example will pull in *all* the exported symbols from mycode.a but only *unresolved* symbols from otherarchive.a. Hope this helps, Jack D. -- ============================================================================== Daylight Chemical Information Systems, Inc. | Jack Delany 441 Greg Ave. | 505-989-1000 x205 Santa Fe, New Mexico 87501 | 505-989-1200 (fax) http://www.daylight.com/ | jjd...@da... ============================================================================== |