Subject: RE: Making cygnus-win32 libraries from DLLs
From: [email-masked] (Colin Peters)

31 Aug 1997 06:53:56 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <01BCB3A8.5EED0300.cygnus.gnu-win32@gbird0>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="---- =_NextPart_000_01BCB3A8.5EF62AC0"
Original-To: "'Chris Kirgios'" <[email-masked]>
Original-Cc: "'GNU-Win32'" <[email-masked]>
Original-Sender: [email-masked]

------ =_NextPart_000_01BCB3A8.5EF62AC0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Chris Kirgios[SMTP:[email-masked]] wrote:
>I have a similar problem  with Minh Le Cong to whom you replied in the =
cygnus mailing list. I have ported all my C++ code from Solaris to =
Windows NT with the exception of a library that uses Oracle Pro*C/C++ =
(embedded SQL). Modules that link with this library must link with an =
Oracle dll. Question: How do I link my g++ linked code with that =
library/dll?=20
>
>I am an NT 'ignorant' so I appreciate all the help and input I can get.

I have heard a few people ask this question, so I dug around a bit in my
files and found out that the program best suited for this is not really
dumpexts (that works with object files) but one posted by Ismael Jurado
<[email-masked]> way back in April called impdef. I've included the
source code and will put up the source and exe on my web site shortly.
This program compiles and works on my system with no modifications =
(since
it includes the missing info from the winnt.h header than dumpexts does
not).

Anyway, here's how it works.

Assuming you have a .dll and the appropriate .h files (you don't =
actually
need the .lib at all) run impdef on the .dll:

  impdef foo.dll >foo.def

Then run foo.def through dlltool to get a libfoo.a file:

  dlltool --dllname foo.dll --def foo.def --output-lib libfoo.a -k

NOTE: Don't let the --dllname argument fool you. Dlltool does NOT look
for any file called foo.dll and definitely does NOT extract the exports
and create the right library for them. You need impdef. The dllname is
just the name that is put into the library to mark what file should be
loaded to resolve the imports (don't put a path name in here, just the
basic file name).

Compile your code including the .h files and linking with the libfoo.a
library. Your code, upon execution, will search for foo.dll and resolve
the references to the functions within it (if all goes well).

That's it, good luck.

Colin.

PS. Apologies to earlier inquirers, including Minh Le Cong, who were
told that dumpexts didn't do the job I thought it would. It doesn't,
but impdef does.

=20
-- Colin Peters - Saga Univ. Dept. of Information Science
-- [email-masked] - finger for PGP public key
-- http://www.fu.is.saga-u.ac.jp/~colin/index.html
-- http://www.geocities.com/Tokyo/Towers/6162/

------ =_NextPart_000_01BCB3A8.5EF62AC0
Content-Type: application/octet-stream; name="impdef.cpp"
Content-Transfer-Encoding: base64

------ =_NextPart_000_01BCB3A8.5EF62AC0--

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