Reputation: 13
I am using a c++ Code , and i included SFML library set the linker ,library, and dependencies and trying to compile it with gcc/g++ but that does not work althoug the code work 100% when i run it in VS . i am using VS 2017 , already installed MinGW and i gave that in terminal(i was already in the path where that .cpp file is) gcc Main.cpp -I "path../include/" -L "path.../lib" -l sfml-graphics -l sfml-window -l sfml-system
i get always the same problem for graphics,window and system , and idea guys ?
"C:/Program Files/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\path\SFML\lib/sfml-graphics.lib when searching for -lsfml-graphics
C:/Program Files/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\path\lib/sfml-graphics.lib when searching for -lsfml-graphics
C:/Program Files/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\path\SFML\lib\sfml-graphics.lib when searching for -lsfml-graphics
C:/Program Files/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsfml-graphics"
Upvotes: 1
Views: 994
Reputation: 2613
*.lib
files are for the Visual Studio/MSVC linker and not for MinGW/GCC. For MinGW you'll need the *.a
import libraries.
As mentioned in the comments, you'll need to grab a MinGW SFML SDK package and you can't reuse the Visual Studio one.
On top of that the version which was used to compile SFML needs to match 100% the version you use to compile your application and link SFML. And by 100% I really mean 100%. It can't have a similar name or just some small version difference. There's no ABI stability for C++ libraries, so you can't reuse them for multiple compilers.
If compiler and the package don't match and you don't want to switch compiler, the easiest solution is to build SFML from source with CMake.
Upvotes: 0