delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/08/27/03:49:13

From: esstech AT ess400 DOT com (Paul Herzog)
Subject: More fun with DLL's
27 Aug 1998 03:49:13 -0700 :
Message-ID: <01BDD0F7.112D4180.cygnus.gnu-win32@sparkle.powerpg.com>
Mime-Version: 1.0
To: "'GNU-WIN32'" <gnu-win32 AT cygnus DOT com>

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 AT 8 as expected.
To build my DLL export table, I use the following .def file:

// mylib-exp.lib
LIBRARY MYLIB
EXPORTS
	myFunc=myFunc AT 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 AT 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 AT 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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019