SFML community forums
Help => General => Topic started by: unabletobereached on July 14, 2015, 01:57:09 am
-
So earlier today I tried setting up SFML using the latest version of Code::Blocks. I used the start up guide provided on the page and at this point have tried both the GCC 4.9.2 MinGW (DW2) - 32-bit version and the GCC 4.8.1 TDM (SJLJ) - 32-bit version of SFML. When ever I try to build the simple test file (the drawing of a green circle) I get the following error:
||=== Build: Release in CPP_2D_Basics (compiler: GNU GCC Compiler) ===|
ld.exe||cannot find -lsfml-graphics|
ld.exe||cannot find -lsfml-window|
ld.exe||cannot find -lsfml-system|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Does anyone have any idea why this is happening?
-
The error tells what's happening. It can't find the libraries to link. You need to specify the directory where the SFML *.a file are located. See the official tutorial.
-
So are you saying that under the second step of the tutorial that I should have a full path like "SFML-2.3.1\lib\libsfml-graphics.a" as opposed to just "sfml-graphics"? Because the tutorial itself says "the "lib" prefix and the ".a" extension must be omitted".
-
Unless the library is in one of the compilers standard search paths then you must tell it where they are (the -L (https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gcc/Directory-Options.html#Directory-Options) switch for gcc).
You should also look into the -rpath option. Especially the $ORIGIN bit. See for example this: https://enchildfone.wordpress.com/2010/03/23/a-description-of-rpath-origin-ld_library_path-and-portable-linux-binaries/
-
I probably should have said this earlier, but I'm on windows 8.1, and that -rpath description might have just confused me more, especially if that technique on linux is still relevant for windows....
-
Ok. Let me try to keep it simple and plain.
You are using gcc. When linking to a library you specify the name of the library with the -l switch. This name should not contain the "lib" prefix or the ".so|.a" suffix. The compiler also needs to know where to find the library. It first searches some pre-defined locations and if it is not found there it searches extra locations that you have told it about and you tell it that with the -L switch (which takes a path argument). The OS doesn't matter here, only the compiler in use.
-
Okay, so when my compiler errors and says that it cannot find the -lsmfl-graphics, it's referring to the -l switch your talking about. So then as far as specifying that, should I be looking in my project build options or in the actual compiler settings? I assume the latter, and if I assume correctly, should I just specify the same paths that I was told to specify in the tutorial within the global compiler linker settings?
-
I can't tell you what to do in Code::Blocks - I don't use it.
Personally I use Emacs and drive the build with SCons. I'm just telling you what underlying gcc arguments are involved (btw: note the difference between the lowercase -l option which specifies the lib name and the uppercase -L option which specifies dirs to search).
Edit: note also that this really has nothing to do with SFML as such. You'd be facing this challenge regardless of what library you were trying to use.
-
Did you set up the compiler and linker search directories as it says in the tutorial? I think that's codeblocks' equivalent to what Jesper was saying.
-
Yeah I did. If it helps at all, the following is what the build log says:
-------------- Build: Release in CPP_2D_Basics (compiler: GNU GCC Compiler)---------------
x86_64-w64-mingw32-g++.exe -L"SFML-2.3.1 x86\lib" -o bin\Release\CPP_2D_Basics.exe obj\Release\main.o -s -lsfml-graphics -lsfml-window -lsfml-system
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible SFML-2.3.1 x86\lib/libsfml-graphics.a when searching for -lsfml-graphics
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible SFML-2.3.1 x86\lib\libsfml-graphics.a when searching for -lsfml-graphics
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible SFML-2.3.1 x86\lib/libsfml-graphics.a when searching for -lsfml-graphics
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsfml-graphics
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible SFML-2.3.1 x86\lib/libsfml-window.a when searching for -lsfml-window
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible SFML-2.3.1 x86\lib\libsfml-window.a when searching for -lsfml-window
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible SFML-2.3.1 x86\lib/libsfml-window.a when searching for -lsfml-window
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsfml-window
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible SFML-2.3.1 x86\lib/libsfml-system.a when searching for -lsfml-system
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible SFML-2.3.1 x86\lib\libsfml-system.a when searching for -lsfml-system
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible SFML-2.3.1 x86\lib/libsfml-system.a when searching for -lsfml-system
C:/Program Files/mingw-w64/x86_64-4.9.0-posix-seh-rt_v3-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsfml-system
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
3 error(s), 0 warning(s) (0 minute(s), 0 second(s))
-
Well didn't you think it might be important as well? ::)
I mean it literally says "skipping incompatible [...]libsfml-graphics.a when searching for -lsfml-graphics"
You're using a 64-bit compiler and try to link against 32-bit library files. That's not going to work. Use the 64-bit library files instead. ;)
-
Wow I feel dumb. I didn't even think to check that since most compilers are 32bits -_- Thanks so much for pointing that out for me
-
Just an FYI: the 64 bit gcc tarball appears to have 32-bit binaries...
-
Which tarball are you talking about?
-
Linux gcc 64 bit