Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Setting Up SFML  (Read 6789 times)

0 Members and 1 Guest are viewing this topic.

unabletobereached

  • Newbie
  • *
  • Posts: 6
    • View Profile
Setting Up SFML
« 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Setting Up SFML
« Reply #1 on: July 14, 2015, 09:28:30 am »
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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

unabletobereached

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Setting Up SFML
« Reply #2 on: July 14, 2015, 04:57:57 pm »
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".

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Setting Up SFML
« Reply #3 on: July 14, 2015, 05:20:58 pm »
Unless the library is in one of the compilers standard search paths then you must tell it where they are (the -L 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/

unabletobereached

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Setting Up SFML
« Reply #4 on: July 14, 2015, 05:51:37 pm »
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....

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Setting Up SFML
« Reply #5 on: July 14, 2015, 06:05:03 pm »
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.

unabletobereached

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Setting Up SFML
« Reply #6 on: July 14, 2015, 06:37:25 pm »
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?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Setting Up SFML
« Reply #7 on: July 14, 2015, 07:07:42 pm »
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.
« Last Edit: July 14, 2015, 07:15:02 pm by Jesper Juhl »

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Setting Up SFML
« Reply #8 on: July 14, 2015, 10:18:32 pm »
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.

unabletobereached

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Setting Up SFML
« Reply #9 on: July 14, 2015, 11:09:17 pm »
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))

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Setting Up SFML
« Reply #10 on: July 14, 2015, 11:36:06 pm »
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. ;)
« Last Edit: July 14, 2015, 11:38:01 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

unabletobereached

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Setting Up SFML
« Reply #11 on: July 15, 2015, 12:43:03 am »
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

idg3t

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Setting Up SFML
« Reply #12 on: July 16, 2015, 05:41:59 am »
Just an FYI: the 64 bit gcc tarball appears to have 32-bit binaries...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Setting Up SFML
« Reply #13 on: July 16, 2015, 08:40:32 am »
Which tarball are you talking about?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

idg3t

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Setting Up SFML
« Reply #14 on: July 16, 2015, 09:07:37 am »
Linux gcc 64 bit

 

anything