I'm trying to cross-compile on Linux (i686-w64-mingw32-gcc) a small 32-bit Windows program that requires (libz, libpng and) libgd. I have them all installed correctly, as far as I can tell, though the linker keeps on complaining it can't locate the libgd functions I'm using.
$ i686-w64-mingw32-gcc -lgd -lpng -lz -lm -o demo demo.o smssc.o
demo.o:demo.c:(.text+0x2d): undefined reference to `_imp__gdImageCreateFromPng@4'
demo.o:demo.c:(.text+0x1f7): undefined reference to `_imp__gdImageGetPixel@12'
demo.o:demo.c:(.text+0x316): undefined reference to `_imp__gdImageCreate@8'
demo.o:demo.c:(.text+0x368): undefined reference to `_imp__gdImagePaletteCopy@8'
demo.o:demo.c:(.text+0x3b0): undefined reference to `_imp__gdImageGetPixel@12'
demo.o:demo.c:(.text+0x3ec): undefined reference to `_imp__gdImageSetPixel@16'
demo.o:demo.c:(.text+0x430): undefined reference to `_imp__gdImageDestroy@4'
demo.o:demo.c:(.text+0x465): undefined reference to `_imp__gdImageSetPixel@16'
demo.o:demo.c:(.text+0x4a9): undefined reference to `_imp__gdImageSetPixel@16'
demo.o:demo.c:(.text+0x4e0): undefined reference to `_imp__gdImageColorAllocate@16'
demo.o:demo.c:(.text+0x569): undefined reference to `_imp__gdImageLine@24'
demo.o:demo.c:(.text+0x5e9): undefined reference to `_imp__gdImageLine@24'
demo.o:demo.c:(.text+0x669): undefined reference to `_imp__gdImageLine@24'
demo.o:demo.c:(.text+0x6e3): undefined reference to `_imp__gdImageLine@24'
demo.o:demo.c:(.text+0x70f): undefined reference to `_imp__gdImagePng@8'
demo.o:demo.c:(.text+0x71f): undefined reference to `_imp__gdImageDestroy@4'
this is how I had configured libgd
./configure --host=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32 CPPFLAGS="-I/usr/i686-w64-mingw32/include" LDFLAGS="-L/usr/i686-w64-mingw32/lib"
of course libgd.a, libpng.a and libz.a are found into my /usr/i686-w64-mingw32/lib
also, objdump output seems correct:
$ objdump -tT /usr/i686-w64-mingw32/lib/libgd.a
In archive /usr/i686-w64-mingw32/lib/libgd.a:
gd.o: file format pe-i386
[snip]