On Mon, 15 Mar 2004, Alan Lehotsky wrote:
> Using MINGW (gcc 3.3.2, binutils 2.14) I create a DLL and both the
> import library and a .def file.
> I have created the import library either by running dlltool on the .def file
> dlltool -d dll.def -l dll.lib -D dll.dll
> or by passing a linker flag thru gcc viz,
> gcc -shared -o dll.dll dll.o -Wl,--out-implib=dll.lib ....
> Link under Visual C 6.0 using that MINGW generated import library
> results in crashes when executing the linked image. On stepping my way
> thru the code, I see that the jmp instruction that should transfer
> control into the dll entrypoint has a relocated address that points to
> unallocated memory.
> If I link the whole application using the MINGW tools and then run the
> resulting image on Windows or Wine, it works just fine.
> If I take the .def file and use the MS lib tool command
> lib /machine:i386 /def:library.def
> I get an import library that successfully links using Visual C 6.0.
> Any ideas why dlltool and the MINGW linker are failing for me? Is there
> some expectation that I will dynamically load the DLL?
LIB files are not standard across development tools. You pretty
much have to build them using the same tool that you plan to use
There was (no longer maintained, I believe) a "selfhost" version
of Mingw which had a dlltool that would generate valid VC LIB
files; I got it working some time ago for VC6 with some minor
tweaks but haven't done much else with it.
Since I need VC6 for testing anyway, I didn't pursue it but
build with the following:
gcc -shared -o dll.dll dll.o \
lib /machine:ix86 /def:dll.def /out:dll.msvc.lib
I end up generating: dll.dll, dll.gcc.lib, dll.msvc.lib, and
Then use the appropriate LIB file, depending on which linker
I'm using for the application.
> I've objdumped both the lib-generated and dlltool-generated libraries
> and they are drastically different. There are no obvious (to me)
> distinctions in the differences however....
Yes, they are.
Daylight Chemical Information Systems, Inc. | Jack Delany
441 Greg Ave. | 505-989-1000 x205
Santa Fe, New Mexico 87501 | 505-989-1200 (fax)
http://www.daylight.com/ | jjdelany@...