This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Making cygnus-win32 libraries from DLLs


Chris Kirgios[SMTP:ckirgios@ajboggs.com] 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? 
>
>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
<ismaelj@hotmail.com> 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.

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

impdef.cpp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]