Search code examples
c++openglgccsoil

Using SOIL.lib with GCC - Error adding symbols: File format not recognised


I've been recently trying to transfer my Visual Studio OpenGL project to VS Code, using GCC via mingw-x64 on Windows 10. I've been making steady progress working this all out as I am fairly new to c++ programming, and I've been running into an error that I can't solve.

When building with the following command:

C:\Lib\mingw-w64\mingw64\bin\g++.exe -LC:/Lib/lib -IC:/Lib/include -g main.cpp -lglew32 -lglfw3 -lSOIL -lopengl32 -o build.exe

I've been getting this error:

C:/Lib/lib/SOIL.lib: error adding symbols: File format not recognized
collect2.exe: error: ld returned 1 exit status

The SOIL.lib I am using worked fine for Visual Studio, and GCC seems to have no complaints with the other .lib files I am using.

There doesn't seem to be much information about what's happening, I've found a bunch of different people having the same error for different things, and I haven't been able to work out what is actually going wrong for this cryptic error message. Can anyone help out?


Solution

  • *.lib: error adding symbols: File format not recognized.

    is the issue which is caused by your linker. The reason behind this is the library is belongs to other architecture rather than you are intended it to be.

    That means you are using mingw64\bin\g++.exe compiler(mingw64 architecture) and the library SOIL.lib is built for your host system architecture(which is obviously different than mingw64 architecture).

    If you want to compile this you have to get the SOIL.lib built for mingw64.