Subject: RE: DLL to lib*.a?
From: [email-masked] (Colin Peters)

2 Apr 1997 08:29:47 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <01BC3F6D.4E2712E0.cygnus.gnu-win32@gbird0>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Original-To: "[email-masked]" <[email-masked]>,
        "'David W Palmer'"
	 <[email-masked]>
Original-Sender: [email-masked]

David W Palmer[SMTP:[email-masked]] wrote:
>     Has this made it to the FAQ yet?  Try the following:
>     
>     dlltool --dllname ouch.dll --output-lib libouch.a
>     
>     Replace "ouch" with the DLL's base name for both ouch.dll and 
>     libouch.a.
[snip]
>Is there any tool or something available to turn a DLL into a lib*.a? 
>Or any other way to use functions in a DLL?

I'd like to point out that this solution doesn't actually work. What
the given command will do is indeed create a library libouch.a, but
that library will contain only the basic header information and no
actual function exports. The option --dllname simply instructs
dlltool what name to put into the library (which will be used by the
loader code to find the actual file, which is why, by the way, you
should never put a path in here, especially an absolute path).

To generate a library from a DLL you have to generate a .def file
containing a list of exports and then use

  dlltool --def ouch.def --dllname ouch.dll --output-lib libouch.a

to generate the library. If the dll contains symbol information you
can use "nm | grep T" to get a list of function names which you can
use to make your .def file, or you can use Windows 95's "Quick View"
function to examine the exports of the DLL directly (more reliable,
since this will not include internal symbols like, for example,
__CTOR_LIST__ and such, and it works on files without symbols).

The def file can be simply the word "EXPORTS" followed by the names
of the functions to be exported, one per line, like this:

EXPORTS
foo
bar

Good luck,

Colin.

-- Colin Peters - [email-masked]
-- Saga University Dept. of Information Science
-- http://www.fu.is.saga-u.ac.jp/~colin/index.html
-- http://www.geocities.com/Tokyo/Towers/6162/

-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".