DLL: File format not recognised when compiling C w

2019-07-07 19:07发布

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...

2条回答
We Are One
2楼-- · 2019-07-07 19:47

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.

查看更多
祖国的老花朵
3楼-- · 2019-07-07 19:52

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.

查看更多
登录 后发表回答