More fun with DLL's

Paul Herzog esstech@ess400.com
Wed Aug 26 13:44:00 GMT 1998


I think I've got the best of both worlds now, at the cost of 3  .def files for each DLL.  If I were more motivated, I might look to generate one def file from the other, or generate all the def files from the .o files directly ( I thought someone was doing this already...)

In my source, i have:

// mylib.c
int WINAPI myFunc(int arg1, int arg2)
{
return arg1 + arg2;
}



After compilation, my .o file has the symbol _myFunc@8 as expected.
To build my DLL export table, I use the following .def file:

// mylib-exp.lib
LIBRARY MYLIB
EXPORTS
	myFunc=myFunc@8

and the command lines ==>  
gcc -mdll -o junk.tmp -Wl,--base-file,base.tmp mylib.o
dlltool --dllname mylib.dll --def mylib-a.def -k --output-exp libmylib.exp --base-file base.tmp

This leaves me with a DLL that exports and associates the symbol 
myFunc with the code at entry point _myFunc@8 from my .o file


Now, if I want to make an MS Link.exe library, i use the following DEF File:

// mylib-ms.def
LIBRARY MYLIB
EXPORTS
	myFunc


and the command line ==>  
lib /DEF:mylib-ms.def


Finally, to make a libmylib.a file, i use the following DEF File:

// mylib-a.def
LIBRARY MYLIB
EXPORTS
	myFunc@8=myFunc


and the command line ==>  
dlltool --dllname mylib.dll --def mylib-a.def -k --output-lib libmylib.a


So, I have a DLL that is GetProcAddress() friendly (it doesn't include the @nn decorations in the exported symbols),
and I have a library for people who insist on using msvc, and I have a lib*.a file to use the DLL from other gcc compiled/linked projects.

Pretty gross huh?

--
Paul Herzog

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list