DLL: File format not recognised when compiling C w

2019-07-07 19:33发布

问题:

I'm using MinGW on Linux (Ubuntu, specifically) to compile a C program for Windows. I'm using a library called SFML, and it's bindings called CSFML. I'm using -L and -l to locate the libraries, but when I compile I get this error:

win32/dll/csfml-audio-2.dll: file not recognized: File format not recognised

I've got no idea why. Here's the command I'm using to compile:

sudo i686-w64-mingw32-gcc -o wandering src/main.c src/constants.c src/Display/display.c **...some more c files in here...** src/Generation/perlinnoise.c $(pkg-config --libs --cflags glib-2.0) $(pkg-config --libs --cflags gee-1.0) -Iwin32/CSFML-2.1/include -Lwin32/dll -lcsfml-audio-

Does anyone know why it's happening? I can compile C programs without SFML but with MinGW just fine...

回答1:

The DLL has a PE32 executable file header. It's not used for the linker. You should use the import library instead. This file has the extension LIB.

I heard there are some gcc compiler versions out there than generate an import library from a DLL on the fly. It looks like your version doesn't.



回答2:

From command line it seem's trying to use sudo i686-w64-mingw32-gcc 64 bit compiler and supplying 32 bit DLL i.e. win32/dll/csfml-audio-2.dll. change to x64/dll/csfml-audio-2.dll. It should work fine.