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

Author Topic: SFML 2.0 in Linux giving linking errors  (Read 2662 times)

0 Members and 1 Guest are viewing this topic.

robvleugel

  • Newbie
  • *
  • Posts: 29
    • View Profile
SFML 2.0 in Linux giving linking errors
« on: February 12, 2012, 06:27:55 pm »
Hello,

I've been using SFML (1.6) on Windows for a while now and I love it!
However, I'm having trouble setting it up in Linux (ubuntu 11.10). I
m facing two problems.
I downloaded the latest 2.0 version from github, ran cmake and make to build the libraries. The first problem that I encountered is that I can't seem to make the libsfml-XXX-s-d.a files. For instance, I have libsfml-system.so,libsfml-system.so.2.0,libsfml-system-d.so,libsfml-system-d.so.2.0 and sfmlsystem-d.a.

I find this strange, I did configure with CMake in Debug with BUILD_SHARED_LIBS disabled prior to running make, I tried it again in case I forgot to ran make with this configuration but still no *-s-d.a files.

Next, when I try to compile the code below, it gives me the following errors:

Code: [Select]
Compiling: src/main.cpp
/home/robvleugel/Dev/Projects/XML Test/src/main.cpp: In function ‘int main(int, char**)’:
/home/robvleugel/Dev/Projects/XML Test/src/main.cpp:11:12: error: ‘class sf::Window’ has no member named ‘IsOpened’
/home/robvleugel/Dev/Projects/XML Test/src/main.cpp:14:16: error: ‘class sf::Window’ has no member named ‘GetEvent’
/home/robvleugel/Dev/Projects/XML Test/src/main.cpp:21:77: error: ‘sf::Key’ has not been declared
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings



I hope anyone knows a solution for my problems.
Keep up the good work!

Greetings, Rob


Code: [Select]

#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main(int argc, char** argv) {

sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");


while (App.IsOpened())
{
    sf::Event Event;
    while (App.GetEvent(Event))
    {
        // Window closed
        if (Event.Type == sf::Event::Closed)
            App.Close();

        // Escape key pressed
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
            App.Close();
    }
}

return 0;
}


texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
SFML 2.0 in Linux giving linking errors
« Reply #1 on: February 12, 2012, 06:41:54 pm »
The function IsOpened is now called IsOpen and GetEvent is now called PollEvent.
I think Key has to become Keyboard.

I can't help you with the rest, I always have BUILD_SHARED_LIBS enabled.
TGUI: C++ SFML GUI

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 in Linux giving linking errors
« Reply #2 on: February 12, 2012, 06:56:52 pm »
1. SFML supports static build on Windows only. It doesn't make sense on other OSes, it is strongly recommended to build shared libraries.

2. Read the doc :)
Laurent Gomila - SFML developer

robvleugel

  • Newbie
  • *
  • Posts: 29
    • View Profile
SFML 2.0 in Linux giving linking errors
« Reply #3 on: February 12, 2012, 07:48:04 pm »
Quote from: "Laurent"
1. SFML supports static build on Windows only. It doesn't make sense on other OSes, it is strongly recommended to build shared libraries.

2. Read the doc :)


On 1.: Why is it strongly recommended to build shared libraries and doesn't it make sense on other OS's?

On 2.: Stupid, should've checked the docs first. I didn't really expected to see changes in existing classes and functions while upgrading to 2.0. Guess I'll have some conversion to do in my existing projects.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 in Linux giving linking errors
« Reply #4 on: February 12, 2012, 08:10:05 pm »
Quote
Why is it strongly recommended to build shared libraries and doesn't it make sense on other OS's?

Because, unlike Windows, Unix OSes manage shared library very smartly. There's no reason not to use them.

Static libraries waste space on your hard drive, and make updates impossible without recompiling the final app. Moreover, since a static library has not been linked to its dependencies, you would have to link all the SFML's dependencies yourself in each app that uses it.

Static libraries are only useful on Windows, where shared libraries are a total mess.
Laurent Gomila - SFML developer

robvleugel

  • Newbie
  • *
  • Posts: 29
    • View Profile
SFML 2.0 in Linux giving linking errors
« Reply #5 on: February 12, 2012, 09:24:11 pm »
Thanks for the info, this has been a great help!

 

anything