1
votes

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"

1
Does it solve your problem? stackoverflow.com/questions/14990222/…zkoza
Unfortunately, it did not work i have tha same 32-bit version for MinGW,Build configuration,SFML Library..etc i tried almost every solution i fount in internet , but nothing work for me thank you zkozaMahmoud
Perhaps gcc and VS need different libraries? That is, perhaps you need SFML compiled specifically for mingw under Windows? Or even for mingw compiled for the particular Windows you use?zkoza
According to sfml-dev.org/download/sfml/2.5.1 there are 9 (yes: nine) SFML ports to Windows. This includes three MinGW ports. Are you sure yours matches the compiler you use? See stackoverflow.com/questions/30739099/… and the discussion about SEH, SJLJ and DW2 here: github.com/sous-chefs/mingw/blob/master/README.mdzkoza
thank you very much zkoza , i gave up now , nothing worked for windows but i tried to compile my code in Linux , and it worked without any problem the Problem that i could not understand is that i have an *.o file and in my *.cpp file where my code should be , i dont find any code , just Symbols that have no meaning do u have any idea ? i dont know even about what should i make a search to figure that outMahmoud

1 Answers

0
votes

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