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: Building an import lib from a DLL - egcs 1.1


Thomas Nichols <thomas.nichols@iname.com> wrote:
>I have a DLL - mSQL.dll from the MiniSQL package at
>http://www.hughes.com.au - for which I want to generate an import library
>for use with the egcs 1.1 compiler. I can't get dlltool to do what I want.
>
>I need basically the same behaviour I'd get from Watcom's wlink
>    - input a DLL
>    - output an import lib with stubs for all exported functions.
>
>Can I do this? Do I have to write a manual DEF file with an entry for each
>export? Do I then have to work out the size of the parameters and set the
>suffix to @4, @8 etc? This is how I got the Bullet library at
>http://www.40th.com - very fast database engine -working some time ago, and
>I don't fancy it for the whole mSQL API. I just want to use the mSQL.dll
>functions in my code while using the egcs compiler - is it possible?


Dlltool can't read the exports of a dll and produce the import library or
.def file, but you don't have to generate them manually (necessarily). There
is a utility called impdef (you can get it at
http://www.geocities.com/Tokyo/Towers/6162/gcc-extra.html ) which will
output the exports of a dll in the correct format for a .def file.
Unfortunately it doesn't work with dlls built with the latest MSVC compilers
(hint hint, anyone available with knowledge and time to fix this?), but it
does work for some third party dlls. Use it like this:

 impdef mSQL.dll >mSQL.def

Then build your import library.

Second problem is stdcall functions (with @nn at the end). This is a real
bugger because there is no way to find out the number to put there just from
the exports of a DLL (if wlink can properly generate such things then it is
doing some magic-- possibly the compiler just doesn't use the @nn convention
for stdcall functions). gcc needs those @'s and the correct numbers in the
.def file. One way to figure out what numbers you need is to try to compile
a program and simply copy the numbers given in the error messages. Luckily
you only have to do this once... it would be nice if you would make it
available for others if you do.

Good luck,
Colin.

- Colin Peters - colin at fu.is.saga-u.ac.jp
- http://www.geocities.com/Tokyo/Towers/6162/index.html
- Go not to usenet for counsel, for it will say both
- 'yes' and 'no' and 'try another newsgroup'.


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


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