1

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"

Mahmoud
  • 13
  • 3
  • Does it solve your problem? https://stackoverflow.com/questions/14990222/skipping-incompatible-cannot-find – zkoza May 30 '21 at 00:51
  • 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 zkoza – Mahmoud May 30 '21 at 07:54
  • 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 May 30 '21 at 16:14
  • According to https://www.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 https://stackoverflow.com/questions/30739099/what-is-the-difference-between-mingw-seh-and-mingw-sjlj and the discussion about SEH, SJLJ and DW2 here: https://github.com/sous-chefs/mingw/blob/master/README.md – zkoza May 30 '21 at 16:23
  • 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 out – Mahmoud Jun 01 '21 at 19:50
  • I don't understand. "I don't find any code" ??? You should have \*.cpp source files and \*.h headers, you *can* have *.o files but that depends on the compiler chain, and you should have a compiled executable. How do you compile in Linux? Out-of-source or in-source (or check what it means)? cmake, make, code::blocks, qtcreator, clion or just a console && bash? – zkoza Jun 01 '21 at 20:12
  • i mean that in my *.cpp file all what i find is symbols , most of them are "^@" i have the *.cpp file and the *.o file nothing else i followed the instructions on the sfml website hier https://www.sfml-dev.org/tutorials/2.5/start-linux.php i used the g++ command , i was on the terminal outside the *.cpp file i tried in/out same Problem – Mahmoud Jun 01 '21 at 21:21
  • Please show the full command line. Also, *.cpp files cannot contain symbols! What is the result of `file *.cpp`? Does it report you have c++ source files or simply text files or something else? You can include these bits of information in your question, after clicking 'Edit' – zkoza Jun 01 '21 at 22:06

1 Answers1

0

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

Lukas
  • 2,461
  • 2
  • 19
  • 32