This has troubled me a couble of times before so I decided to make an example that illustrates the problem. If gcc builds an executable from a static library (or just a regular object file) that imports functions from a dynamic library, then gcc cannot resolve the imports from the import library if the import library is specified before the static library on the command line. E.g.
gcc -o myprogram.exe myprogram.o mydlibrary.a myslibrary.o
will not work, but
gcc -o myprogram.exe myprogram.o myslibrary.o mydlibrary.a
Cross compile i386-mingw32msv from linux
Run the attached example.
Put the import library last on the command line to gcc.
State-Changed-Why: (1) The linker is in the binutils package, not gcc.
(2) The linker is working as designed.