Recent versions of MinGW ld.exe seem to produce
invalid PE DLLs when compiling GNU GMP.
Steps to reproduce:
- Get any recent version of MingMW (2003 or later)
- Download & extract GNU GMP 4.1.4 tarball
- ./configure --disable-static --enable-shared
- make
The resulting libgmp-3.dll seems to be an invalid WIN32
PE file. Attempts to link an app with this DLL cause the
process to fail to load. Attempting LoadLibrary() causes
an access violation (possibly in the MinGW crt startup
code - unsure).
A workaround is to use ld.exe from an old MinGW. The
ld.exe from binutils-2.13.90-20021006-2.tar.gz works
great & produces a usable DLL. The ld.exe from binutils-
2.13.90-20030111-1.tar.gz does NOT work nor do any
later versions.
Juro Bystricky discovered that the issue is something to
do with relocating the DLL to something other than its
preferred base address. More info here:
http://swox.com/list-archives/gmp-discuss/2004-
August/001290.html
Logged In: YES
user_id=11494
What is the command line to build the dll?
Danny
Logged In: YES
user_id=828583
It's a configure/libtool based build:
$ ./configure --disable-static --enable-shared
$ make
Are you asking for just the ld command? It's libtool with
default options as far as I know....
Logged In: YES
user_id=11494
I am asking for you to look at your libtool script and tell me
what options are being passed to ld and (possibly) what
happens to the dll after it is created (eg is the .reloc section
stripped)
It seems strange that other projects can produce relocatable
dlls with new ld but gmp does not
Danny
Logged In: YES
user_id=11494
No feedback in 4 months., It works for me, so closing.
Danny