From: colin AT fu DOT is DOT saga-u DOT ac DOT jp (Colin Peters) Subject: RE: Building an import lib from a DLL - egcs 1.1 7 Oct 1998 15:44:00 -0700 Message-ID: <004201bdf19d$df8a8a80$fa173185.cygnus.gnu-win32@gbird0.fu.is.saga-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit To: "Thomas Nichols" Cc: "GNU-win32" Thomas Nichols 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 AT cygnus DOT com" with one line of text: "help".