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

Author Topic: Problems builind an application with sfml2  (Read 4664 times)

0 Members and 1 Guest are viewing this topic.

dowhile

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problems builind an application with sfml2
« on: June 11, 2012, 10:20:50 pm »
Hello,

I think this problem is not related to the library itself, but I'm hoping to get some support here anyway. I got the RC (C-binding) from the download section and copied the folder to my project location. After I included the libraries and include directory to my project properties in Netbeans, it now generates following gcc call to compile the application:

Quote
gcc -o dist/Debug/GNU-Linux-x86/netspace build/Debug/GNU-Linux-x86/main.o -Lsfml/lib -Wl,-rpath sfml/lib -lcsfml-audio -lcsfml-graphics -lcsfml-network -lcsfml-system -lcsfml-window

ld's response is this:
Quote
/usr/bin/ld: warning: libsfml-graphics.so.2, needed by sfml/lib/libcsfml-graphics.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libsfml-window.so.2, needed by sfml/lib/libcsfml-graphics.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libsfml-system.so.2, needed by sfml/lib/libcsfml-graphics.so, not found (try using -rpath or -rpath-link)
And tons of undefined reference, like
Quote
sfml/lib/libcsfml-graphics.so: undefined reference to `sf::Window::getPosition() const'

How to solve this? The -rpath option is set to sfml/lib, the location of all *.so and *.so.2 files (so they're in the -rpath). Why doesn't ld find those libraries?

Thanks for any response

dowhile

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Problems builind an application with sfml2
« Reply #1 on: June 12, 2012, 09:07:30 pm »
Hello again,

I also tried to compile my main.c test without IDE (I think it's easier to solve the problem this way, but I still dunno what to do), following this tutorial (just with gcc instead of g++).  My file, main.c, is located in CSFML-2.0-rc, so it's in the same folder as include, lib and share are.

Compile:
Quote
$ gcc -c main.c -Iinclude

Build executable:
Quote
$ gcc main.o -o sfml-app -Llib -lcsfml-graphics

/usr/bin/ld: warning: libsfml-graphics.so.2, needed by lib/libcsfml-graphics.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libsfml-window.so.2, needed by lib/libcsfml-graphics.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libsfml-system.so.2, needed by lib/libcsfml-graphics.so, not found (try using -rpath or -rpath-link)
lib/libcsfml-graphics.so: undefined reference to `sf::Window::getPosition() const'
lib/libcsfml-graphics.so: undefined reference to `sf::String::toAnsiString(std::locale const&) const'
...
So it's the same result, just without the overhead from the IDE.

The error message tells me to use the -rpath option, but I neither know how to use it nor what exactly the option does. Since the error is not related to runtime (isn't it?), why must I set the "runtime" path?

EDIT: I tried to involve the -rpath option this way:
Quote
daniel@daniel-desktop:~/CSFML-2.0-rc$ gcc main.o -o sfml-app -Llib -lcsfml-graphics -Wl,-rpath /home/daniel/CSFML-2.0-rc/lib
But it's still the same error.
« Last Edit: June 12, 2012, 09:22:39 pm by dowhile »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problems builind an application with sfml2
« Reply #2 on: June 12, 2012, 10:02:48 pm »
CSFML depends on SFML, did you install it first?
Laurent Gomila - SFML developer

dowhile

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Problems builind an application with sfml2
« Reply #3 on: June 12, 2012, 10:13:39 pm »
CSFML depends on SFML, did you install it first?
You're so right! I read over the "c" in libcsfml-graphics.so.2 and thought they're the required libraries. I really didn't notice that I need other ones.   :-[

Thanks for your help.

 

anything