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

Author Topic: Won't compile  (Read 5583 times)

0 Members and 1 Guest are viewing this topic.

Law

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Won't compile
« on: July 10, 2014, 06:47:30 pm »
Hello, here is my very simple file SFML.cpp :

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

using namespace std;

int main(int argc, char **argv)
{
    sf::RenderWindow Window(sf::VideoMode(800, 600), "My Window :D");
    sf::Texture Sprite;
    Window.clear(sf::Color::Black);
    Window.display();
    return 0;
}

I try to compile it :

g++-4.8 -std=c++11 -o SFML SFML.cpp -Wall -lsfml-graphics -lsfml-window -lsfml-system

And here is what I get :

/tmp/ccg01oFm.o: In function `main':
SFML.cpp:(.text+0x104): undefined reference to `sf::String::String(char const*, std::locale const&)'
SFML.cpp:(.text+0x155): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
SFML.cpp:(.text+0x182): undefined reference to `sf::Texture::Texture()'
SFML.cpp:(.text+0x19a): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
SFML.cpp:(.text+0x1a9): undefined reference to `sf::Window::display()'
SFML.cpp:(.text+0x1bd): undefined reference to `sf::Texture::~Texture()'
SFML.cpp:(.text+0x212): undefined reference to `sf::Texture::~Texture()'
collect2: error: ld returned 1 exit status

Would you know how to fix this? Thanks.

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Re: Won't compile
« Reply #1 on: July 10, 2014, 06:55:31 pm »
What distribution are you using? are you sure that SFML is installed? are you sure SFML is installed in standard path?
You can check if it's installed in standard path by going in /usr/share and check if libsfml-dev is there.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Won't compile
« Reply #2 on: July 10, 2014, 07:05:13 pm »
From what you posted it seems that it compiles just fine but it doesn't link (since what you posted are linker errors).
So, are you sure you are properly linking all required libraries (in correct order - yes, order matters)? Are you sure you've correctly told the linker where to find those libraries?

Law

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Won't compile
« Reply #3 on: July 10, 2014, 07:33:36 pm »
What distribution are you using? are you sure that SFML is installed? are you sure SFML is installed in standard path?
You can check if it's installed in standard path by going in /usr/share and check if libsfml-dev is there.
I do not have any libsfml-dev folder in /usr/share/, however /usr/local/lib/ and /usr/local/include/ contain everything they need. So I guess the problem is that libsfml-dev folder missing in /usr/share/. How do I fix this, cleanly?

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Re: Won't compile
« Reply #4 on: July 10, 2014, 08:47:07 pm »
Sorry I meant usr/lib/i386-linux-gnu (this depends if you have 32 or 64bit instalation)

Have you installed SFML via repository? What Linux distribution are you using?
When you are in terminal did you cd to the directory where is your .cpp ?
Also why are you not using IDE like codeblocks?
« Last Edit: July 10, 2014, 08:50:06 pm by paupav »

Law

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Won't compile
« Reply #5 on: July 10, 2014, 09:13:38 pm »
Sorry I meant usr/lib/i386-linux-gnu (this depends if you have 32 or 64bit instalation)

Have you installed SFML via repository? What Linux distribution are you using?
When you are in terminal did you cd to the directory where is your .cpp ?
Also why are you not using IDE like codeblocks?
Nothing there either. I have Ubuntu 12.04 LTS. 64 bits. My .cpp file is located in some random directory in Home.

I must say I do not quite remember how I installed SFML, it was a few months ago, my .cpp file couldn't compile and I gave up. Now I'm trying to make things work again. I'm pretty sure I installed it through "sudo apt-get install" commands though.

If I type:

sudo apt-get install libsfml-dev

I get:

Reading package lists... Done
Building dependency tree      
Reading state information... Done
libsfml-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.

So basically my computer tells me everything is perfect, yet nothing works!

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Re: Won't compile
« Reply #6 on: July 10, 2014, 09:19:12 pm »
Sorry I meant usr/lib/i386-linux-gnu (this depends if you have 32 or 64bit instalation)

Have you installed SFML via repository? What Linux distribution are you using?
When you are in terminal did you cd to the directory where is your .cpp ?
Also why are you not using IDE like codeblocks?
Nothing there either. I have Ubuntu 12.04 LTS. 64 bits. My .cpp file is located in some random directory in Home.

I must say I do not quite remember how I installed SFML, it was a few months ago, my .cpp file couldn't compile and I gave up. Now I'm trying to make things work again. I'm pretty sure I installed it through "sudo apt-get install" commands though.

If I type:

sudo apt-get install libsfml-dev

I get:

Reading package lists... Done
Building dependency tree      
Reading state information... Done
libsfml-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.

So basically my computer tells me everything is perfect, yet nothing works!
Ok, I see the problem. Ubuntu 12.04 doesn't have SFML 2.1 in it's repositories you can only install SFML 1.6. I would suggest you to upgrade to Ubuntu 14.04 LTS since it has SFML 2.1 in its repositroyes. Ubuntu 14.04 is also faster and you can install newer versions of applications.
Here is how to upgrade: http://www.omgubuntu.co.uk/2014/04/upgrade-ubuntu-14-04-12-04

Basically just write:
sudo update-manager -d
in terminal

Law

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Won't compile
« Reply #7 on: July 10, 2014, 09:23:08 pm »
Sorry I meant usr/lib/i386-linux-gnu (this depends if you have 32 or 64bit instalation)

Have you installed SFML via repository? What Linux distribution are you using?
When you are in terminal did you cd to the directory where is your .cpp ?
Also why are you not using IDE like codeblocks?
Nothing there either. I have Ubuntu 12.04 LTS. 64 bits. My .cpp file is located in some random directory in Home.

I must say I do not quite remember how I installed SFML, it was a few months ago, my .cpp file couldn't compile and I gave up. Now I'm trying to make things work again. I'm pretty sure I installed it through "sudo apt-get install" commands though.

If I type:

sudo apt-get install libsfml-dev

I get:

Reading package lists... Done
Building dependency tree      
Reading state information... Done
libsfml-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.

So basically my computer tells me everything is perfect, yet nothing works!
Ok, I see the problem. Ubuntu 12.04 doesn't have SFML 2.1 in it's repositories you can only install SFML 1.6. I would suggest you to upgrade to Ubuntu 14.04 LTS since it has SFML 2.1 in its repositroyes. Ubuntu 14.04 is also faster and you can install newer versions of applications.
Here is how to upgrade: http://www.omgubuntu.co.uk/2014/04/upgrade-ubuntu-14-04-12-04

Basically just write:
sudo update-manager -d
in terminal
Hmm okay, I would have to think about it a bit...

Wouldn't it be simpler if I just added the right repositories ? Would you know what they are, and how to add them?

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Re: Won't compile
« Reply #8 on: July 10, 2014, 09:33:01 pm »
Sorry I meant usr/lib/i386-linux-gnu (this depends if you have 32 or 64bit instalation)

Have you installed SFML via repository? What Linux distribution are you using?
When you are in terminal did you cd to the directory where is your .cpp ?
Also why are you not using IDE like codeblocks?
Nothing there either. I have Ubuntu 12.04 LTS. 64 bits. My .cpp file is located in some random directory in Home.

I must say I do not quite remember how I installed SFML, it was a few months ago, my .cpp file couldn't compile and I gave up. Now I'm trying to make things work again. I'm pretty sure I installed it through "sudo apt-get install" commands though.

If I type:

sudo apt-get install libsfml-dev

I get:

Reading package lists... Done
Building dependency tree      
Reading state information... Done
libsfml-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.

So basically my computer tells me everything is perfect, yet nothing works!
Ok, I see the problem. Ubuntu 12.04 doesn't have SFML 2.1 in it's repositories you can only install SFML 1.6. I would suggest you to upgrade to Ubuntu 14.04 LTS since it has SFML 2.1 in its repositroyes. Ubuntu 14.04 is also faster and you can install newer versions of applications.
Here is how to upgrade: http://www.omgubuntu.co.uk/2014/04/upgrade-ubuntu-14-04-12-04

Basically just write:
sudo update-manager -d
in terminal
Hmm okay, I would have to think about it a bit...

Wouldn't it be simpler if I just added the right repositories ? Would you know what they are, and how to add them?
Last time I've tried it it was on the Elementary OS which is based on the Ubuntu 12.04. As I remember SFML has it's own dependencies which have their own dependencies. Anyway, you can add debian repositroy which could break your system. Upgrade from Ubuntu 12.04 to 14.04 is much easier. Everything is done by update manager.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Won't compile
« Reply #9 on: July 10, 2014, 09:41:34 pm »
Guys... can you stop quoting full posts? It makes the discussion hardly readable. You know, what you quote is right above, we can find it quite easily ;)
Laurent Gomila - SFML developer

Law

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Won't compile
« Reply #10 on: July 11, 2014, 02:40:25 am »
Okay!

So I'm 14.04 LTS now and my file compiles just fine!
But... When I execute it, here's what I get:

./SFML: error while loading shared libraries: libGLEW.so.1.6: cannot open shared object file: No such file or directory

Almost there!

Edit: Also, now I am experiencing minor problems. I seem to be unable to listen to music through Rhythmbox. Here's what I get once I agreed to install useful packages:

The following packages have unmet dependencies:

gstreamer1.0-plugins-ugly: Depends: libc6 (>= 2.14) but 2.19-0ubuntu6 is to be installed
                           Depends: libdvdread4 (>= 4.1.3) but 4.2.1-2ubuntu1 is to be installed
                           Depends: libgcc1 (>= 1:4.1.1) but 1:4.9-20140406-0ubuntu1 is to be installed
                           Depends: libglib2.0-0 (>= 2.37.3) but 2.40.0-2 is to be installed
                           Depends: liborc-0.4-0 (>= 1:0.4.18) but 1:0.4.18-1ubuntu1 is to be installed
                           Depends: libstdc++6 (>= 4.1.1) but 4.8.2-19ubuntu1 is to be installed
gstreamer1.0-plugins-ugly:i386: Depends: libc6 (>= 2.7) but 2.19-0ubuntu6 is to be installed
                                Depends: libdvdread4 (>= 4.1.3) but 4.2.1-2ubuntu1 is to be installed
                                Depends: libgcc1 (>= 1:4.1.1) but 1:4.9-20140406-0ubuntu1 is to be installed
                                Depends: libglib2.0-0 (>= 2.37.3) but 2.40.0-2 is to be installed
                                Depends: liborc-0.4-0 (>= 1:0.4.18) but 1:0.4.18-1ubuntu1 is to be installed
                                Depends: libstdc++6 (>= 4.1.1) but 4.8.2-19ubuntu1 is to be installed
« Last Edit: July 11, 2014, 02:59:50 am by Law »

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Re: Won't compile
« Reply #11 on: July 11, 2014, 10:09:24 am »
have you tried
sudo apt-get update
sudo apt-get upgrade
after upgrade to Ubuntu 14.04
« Last Edit: July 11, 2014, 10:24:32 am by paupav »

Law

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Won't compile
« Reply #12 on: July 11, 2014, 10:24:58 am »
have you tried
sudo apt-get update
sudo apt-get upgrade
after upgrade to Ubuntu 14.04
I still have the problem.

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Re: Won't compile
« Reply #13 on: July 11, 2014, 10:48:58 am »
This is all what I have installed.

You can download libglew from here: http://pkgs.org/ubuntu-12.04/ubuntu-main-i386/libglew1.6_1.6.0-4_i386.deb.html
« Last Edit: July 11, 2014, 10:52:09 am by paupav »

Law

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Won't compile
« Reply #14 on: July 12, 2014, 01:04:07 pm »
Okay I actually formated my drive and started over. I installed LTS 14.04 and a bunch of updates afterwards, and everything works perfectly now! My file compiles just fine.

Thanks a ton :)

 

anything