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

Author Topic: /usr/bin/ld: cannot find -lsfml-system  (Read 13758 times)

0 Members and 1 Guest are viewing this topic.

Kreshdev

  • Newbie
  • *
  • Posts: 6
    • View Profile
/usr/bin/ld: cannot find -lsfml-system
« on: September 27, 2011, 04:24:32 am »
Greetings!

I am new to this site and I have followed many tutorials and searched before posting this to make sure that it wasn't already explained anywhere and it seems like it doesn't (or I just really suck at searching).
My problem is that when I try to compile a really simple script:
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    // Create the main window
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");

    // Load a sprite to display
    sf::Image Image;
    if (!Image.LoadFromFile("cb.bmp"))
        return EXIT_FAILURE;
    sf::Sprite Sprite(Image);

// Start the game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear screen
        App.Clear();

        // Draw the sprite
        App.Draw(Sprite);

        // Update the window
        App.Display();
    }

    return EXIT_SUCCESS;
}
, I am getting the following errors:
Code: [Select]
ld||cannot find -lsfml-system|
ld||cannot find -lsfml-audio|
ld||cannot find -lsfml-graphics|
ld||cannot find -lsfml-network|
ld||cannot find -lsfml-window|
ld||cannot find -lsfml-graphics-s|
ld||cannot find -lsfml-audio-s|
ld||cannot find -lsfml-window-s|
ld||cannot find -lsfml-network-s|
ld||cannot find -lsfml-system-s|
ld||cannot find -lsfml-graphics-s|
ld||cannot find -lsfml-audio-s|
ld||cannot find -lsfml-network-s|
ld||cannot find -lsfml-window-s|
ld||cannot find -lsfml-system-s|
||=== Build finished: 15 errors, 0 warnings ===|

I have followed this tutorial for the static version and I did everything as told in there. Could anyone please help me out as I feel like this is a really stupid error and I have been looking for a way to fix this issue for a few hours now and I am tired of searching... : /

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
/usr/bin/ld: cannot find -lsfml-system
« Reply #1 on: September 27, 2011, 06:22:11 pm »
It seems you didn't install the release shared version of SFML (ld||cannot find -lsfml-system) and the release static version (ld||cannot find -lsfml-system-s).

Moreover, it seems you are linking your project against BOTH of them; which is wrong. You should only link your project against one type of libraries.

On a side note it's recommended to use shared libraries instead of static libraries on Unix-like OSes. There are plenty of discussion about that on the Internet if you want to know why and how.
SFML / OS X developer

easy

  • Full Member
  • ***
  • Posts: 146
    • MSN Messenger - easy82.contact@gmail.com
    • View Profile
    • Email
/usr/bin/ld: cannot find -lsfml-system
« Reply #2 on: September 28, 2011, 08:12:55 pm »
Hi!

You seem to be on Linux, am I right?

If so, you don't the "-lsfml-xyz" options, it's only for Windows, but you should link the libraries instead, in this order:

Code: [Select]
/usr/local/lib/libsfml-network.so
/usr/local/lib/libsfml-audio.so
/usr/local/lib/libsfml-graphics.so
/usr/local/lib/libsfml-window.so
/usr/local/lib/libsfml-system.so

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
/usr/bin/ld: cannot find -lsfml-system
« Reply #3 on: September 28, 2011, 08:34:31 pm »
Quote from: "easy"
If so, you don't the "-lsfml-xyz" options, it's only for Windows
Nope, you're wrong.  :wink: g++crash course
SFML / OS X developer

Kreshdev

  • Newbie
  • *
  • Posts: 6
    • View Profile
/usr/bin/ld: cannot find -lsfml-system
« Reply #4 on: September 28, 2011, 11:14:00 pm »
Yes, I am on Ubuntu. Could anyone please tell me exactly what to do because I am a bit confused.  >.<

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
/usr/bin/ld: cannot find -lsfml-system
« Reply #5 on: September 29, 2011, 07:50:01 am »
Install SFML to a standard path (/usr/lib or /usr/local/lib for example), don't use the static libraries (-s), and everything should be ok.
Laurent Gomila - SFML developer

Kreshdev

  • Newbie
  • *
  • Posts: 6
    • View Profile
/usr/bin/ld: cannot find -lsfml-system
« Reply #6 on: September 29, 2011, 03:18:35 pm »
Alright, thank you. I will try that out and give you some news soon.

easy

  • Full Member
  • ***
  • Posts: 146
    • MSN Messenger - easy82.contact@gmail.com
    • View Profile
    • Email
/usr/bin/ld: cannot find -lsfml-system
« Reply #7 on: September 29, 2011, 09:48:09 pm »
Quote from: "Hiura"
Quote from: "easy"
If so, you don't the "-lsfml-xyz" options, it's only for Windows
Nope, you're wrong.  :wink: g++crash course


Ok, thanks for the clarification.

What I meant is, the "-lsfml-xyz" directives are just ingored here. They just don't work for me, I had to set the libraries as I've listed them above.

So, Kreshdev, what I suggest is, if you're on Code::Blocks, delete the "-lsfml-*" stuff and set Project/ Build options/ Linker settings/ Link libraries to:

Code: [Select]
/usr/local/lib/libsfml-network.so
/usr/local/lib/libsfml-audio.so
/usr/local/lib/libsfml-graphics.so
/usr/local/lib/libsfml-window.so
/usr/local/lib/libsfml-system.so


These files are at "/usr/local/lib", at least, for me. You should check where these files are on your computer. They also might be at "/usr/lib", for example.

Kreshdev

  • Newbie
  • *
  • Posts: 6
    • View Profile
/usr/bin/ld: cannot find -lsfml-system
« Reply #8 on: September 29, 2011, 11:28:56 pm »
Is it normal if the library files are named, for example:
lsfml-audio.so.1.6
lsfml-etc.so.1.6 or should I rename them to have the .so extension only?
Because it keeps saying
Code: [Select]
/home/tristan/Code::Blocks/SFML/SFML/main.cpp|1|fatal error: SFML/Graphics.hpp: No such file or directory|

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
/usr/bin/ld: cannot find -lsfml-system
« Reply #9 on: September 30, 2011, 07:57:07 am »
Quote
What I meant is, the "-lsfml-xyz" directives are just ingored here. They just don't work for me, I had to set the libraries as I've listed them above.

You must rather add /usr/local/lib to your linker search paths (see ldconfig).

Quote
Is it normal if the library files are named, for example:
lsfml-audio.so.1.6
lsfml-etc.so.1.6 or should I rename them to have the .so extension only?

Yes, there are also symbolic links:
sfml-audio.so -> sfml-audio.so.1.6
etc.

Quote
/home/tristan/Code::Blocks/SFML/SFML/main.cpp|1|fatal error: SFML/Graphics.hpp: No such file or directory|

This has nothing to do with the libraries, it's your compiler that can't find the headers.
Laurent Gomila - SFML developer

Kreshdev

  • Newbie
  • *
  • Posts: 6
    • View Profile
Still experiencing some problems...
« Reply #10 on: January 17, 2012, 11:55:41 pm »
I am still experiencing the "'SFML/Graphics.hpp' no such file or directory" issue.. any idea how to fix it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
/usr/bin/ld: cannot find -lsfml-system
« Reply #11 on: January 18, 2012, 07:55:36 am »
Add the directory that contains the SFML headers to your compiler search paths.
Laurent Gomila - SFML developer

 

anything