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

Author Topic: g++ Compiling error with terminal - First time linux user  (Read 5138 times)

0 Members and 1 Guest are viewing this topic.

guizadin

  • Newbie
  • *
  • Posts: 3
    • View Profile
g++ Compiling error with terminal - First time linux user
« on: May 17, 2013, 09:14:41 pm »
Hello Guys!
So, I just installed linux ubuntu 13.04 and I'm having problems when trying to compile.
I followed all the steps at the SFML tutorial for linux and I'm getting some compiling  problems, I tried different things, like using code::blocks and also geany, but still, having problems.
Here's what I'm trying to compile:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

Now, here's what's happening... At the terminal I use dir>cd Desktop, cause my main.cpp file is there, and after that I use the g++ -c main.cpp and here are the errors I'm getting:


main.cpp: In function ‘int main()’:
main.cpp:6:5: error: ‘CircleShape’ is not a member of ‘sf’
main.cpp:6:21: error: expected ‘;’ before ‘shape’
main.cpp:7:5: error: ‘shape’ was not declared in this scope
main.cpp:9:19: error: ‘class sf::RenderWindow’ has no member named ‘isOpen’
main.cpp:12:23: error: ‘class sf::RenderWindow’ has no member named ‘pollEvent’
main.cpp:14:23: error: ‘class sf::Event’ has no member named ‘type’
main.cpp:15:24: error: ‘class sf::RenderWindow’ has no member named ‘close’
main.cpp:18:16: error: ‘class sf::RenderWindow’ has no member named ‘clear’
main.cpp:19:16: error: ‘class sf::RenderWindow’ has no member named ‘draw’
main.cpp:20:16: error: ‘class sf::RenderWindow’ has no member named ‘display’

I tried looking at the forums but found nothing, so if anyone could help me, that would be really great!
As I said, it's my first time using linux so sorry if I'm being dumb...

Anyways, thanks!



Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: g++ Compiling error with terminal - First time linux user
« Reply #1 on: May 17, 2013, 09:27:55 pm »
You installed SFML 1.6...
Laurent Gomila - SFML developer

guizadin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: g++ Compiling error with terminal - First time linux user
« Reply #2 on: May 17, 2013, 09:40:55 pm »
I used this at terminal
 
sudo apt-get install libsfml-dev

How can I fix that?
Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: g++ Compiling error with terminal - First time linux user
« Reply #3 on: May 17, 2013, 09:56:44 pm »
Uninstall this package, and install SFML 2. Please don't ask "how", just read the tutorial ;)
Laurent Gomila - SFML developer

guizadin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: g++ Compiling error with terminal - First time linux user
« Reply #4 on: May 17, 2013, 10:29:14 pm »
Okay, I'll try that , thanks!

Setzer22

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: g++ Compiling error with terminal - First time linux user
« Reply #5 on: May 19, 2013, 07:47:02 pm »
I'm a begginer as well, and I'd just want to point out that the instructions given in the 2.0 tutorial had lead me to install SFML 1.6, and thus, I was getting the same error as guizadin. I'd suggest someone to fix that, as will for sure lead many more newbies to confusion.

As you can see, in this tutorial http://www.sfml-dev.org/tutorials/2.0/start-linux.php (in the 2.0 section) it clearly states:

Quote
Option 1 is the preferred one; if the version of SFML that you want to install is available in the official repositories then get it with your package manager. For example, on Debian you would do:

sudo apt-get install libsfml-dev

And this package seems to contain the sfml 1.6 header files, at least on ubuntu's repositories.

I guess i'll have to build from source in order to have this running :S

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: g++ Compiling error with terminal - First time linux user
« Reply #6 on: May 19, 2013, 08:10:20 pm »
I thought it was clear enough to say
Quote
if the version of SFML that you want to install is available in the official repositories
Laurent Gomila - SFML developer

hans_larsen

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: g++ Compiling error with terminal - First time linux user
« Reply #7 on: July 26, 2013, 02:14:58 pm »
I am sorry for bumping an old thread, but I just made the same mistake of installing 1.6 thinking I was installing 2.0.

As someone new to SFML and c++ I really think, that you should make people aware that "sudo apt-get install libsfml-dev" doesn't install 2.0 at the moment.

I thought it was clear enough to say
Quote
if the version of SFML that you want to install is available in the official repositories

Looking back it might be clear. But when I read a tutorial about how to install version X, I assume that option 1 leads to installing version X.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: g++ Compiling error with terminal - First time linux user
« Reply #8 on: July 26, 2013, 02:35:10 pm »
Since when do people not check what packages are installed by apt when installing a meta-package?

I just tried and this is the output:
Code: [Select]
~# apt-get install libsfml-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libglew1.5 libopenal1 libsfml-audio1.6 libsfml-graphics1.6 libsfml-network1.6 libsfml-system1.6 libsfml-window1.6 libsoil1
Suggested packages:
  glew-utils libportaudio2 libsfml1.6-dbg libsfml-doc
The following NEW packages will be installed:
  libglew1.5 libopenal1 libsfml-audio1.6 libsfml-dev libsfml-graphics1.6 libsfml-network1.6 libsfml-system1.6 libsfml-window1.6 libsoil1
0 upgraded, 9 newly installed, 0 to remove and 126 not upgraded.
Need to get 737 kB of archives.
After this operation, 2,601 kB of additional disk space will be used.
Do you want to continue [Y/n]?
A bit of reading goes a long way, especially if you care about security or what gets installed on your system at all for that matter...
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

hans_larsen

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: g++ Compiling error with terminal - First time linux user
« Reply #9 on: July 26, 2013, 02:46:01 pm »
Since when do people not check what packages are installed by apt when installing a meta-package?

Apparently we are some, and I am not claiming that we are not stupid.
I am just saying if you want to help stupid people, and if you want to avoid people posting about accidentally installing 1.6 thinking they installed 2.0, you might want to make the tutorial clearer.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: g++ Compiling error with terminal - First time linux user
« Reply #10 on: July 26, 2013, 03:57:18 pm »
Ok, but how to make it clearer than that?

Quote
if the version of SFML that you want to install is available in the official repositories
Laurent Gomila - SFML developer

hans_larsen

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: g++ Compiling error with terminal - First time linux user
« Reply #11 on: July 26, 2013, 04:39:34 pm »
I would either remove option 1, since this is currently not an option. (As far as I understand) And then add the option when 2.0 becomes "available in the official repositories"

Or remove the Debian example until the Debian example installs 2.0.

Anyway I just finished to compile my own version of SFML, and found that tutorial really easy to follow :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: g++ Compiling error with terminal - First time linux user
« Reply #12 on: July 26, 2013, 04:53:36 pm »
The problem is that I'm not going to watch official repos of every Linux distribution to check which ones have SFML 2 and which ones don't. That's why mentioning this option + "if the repo contains the right version" seems to be the most useful thing to do, in my opinion.

Sometimes people need to make mistakes to learn things ;)
Laurent Gomila - SFML developer

khid

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: g++ Compiling error with terminal - First time linux user
« Reply #13 on: December 29, 2013, 11:46:13 am »
"I don't do mistakes, and you should learn from your own ones. ;) TOPIC CLOSED" Pretty classic software development ;D

The topic is misleading no matter how you try to defend it. There is an easy fix, but maybe you should learn from your mistakes. ;)

 

anything