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

Author Topic: linking error while building a sfml project  (Read 1490 times)

0 Members and 2 Guests are viewing this topic.

Arunachalaeshwaran

  • Newbie
  • *
  • Posts: 4
  • I am a SFML noob
    • View Profile
linking error while building a sfml project
« on: August 05, 2016, 09:34:36 am »
hi guys,

I have recently compiled sfml(version 2.3.2) source with gcc/g++(version 4.9.3). Most of it works fine but when I try to build(especially while linking) the program in this http://www.sfml-dev.org/tutorials/2.3/start-linux.php , I get this error:

test.o: In function `main':                                                                                                                                                                     
test.cpp:(.text+0x189): undefined reference to `sf::CircleShape::CircleShape(float, unsigned long)'                                                                                             
collect2: error: ld returned 1 exit status


I have tried reinstalling sfml, but the problem still exists.Also I am on linux mint 17.3(64-bit).
Please, can anyone tell how to solve this problem.

I am sorry for the bad formatting and thanks in advance.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: linking error while building a sfml project
« Reply #1 on: August 05, 2016, 11:05:00 am »
And what's your build command?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Arunachalaeshwaran

  • Newbie
  • *
  • Posts: 4
  • I am a SFML noob
    • View Profile
Re: linking error while building a sfml project
« Reply #2 on: August 05, 2016, 11:22:57 am »
my build compiling command is:
g++ -c test.cpp
This runs without any errors and produces a test.o file.

The error shows up when I link the test.o file.
Command:
g++ test.o -o test -lsfml-graphics -lsfml-window -lsfml-system
This command gives the error that i mentioned in the previous post.

BTW thanks for the reply.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: linking error while building a sfml project
« Reply #3 on: August 05, 2016, 11:35:25 am »
I assume it shouldn't make a difference, but what if you run it in one step?

g++ -o test test.cpp -lsfml-graphics -lsfml-window -lsfml-system
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Arunachalaeshwaran

  • Newbie
  • *
  • Posts: 4
  • I am a SFML noob
    • View Profile
Re: linking error while building a sfml project
« Reply #4 on: August 05, 2016, 12:10:41 pm »
I just ran that now and it shows the same error as before.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: linking error while building a sfml project
« Reply #5 on: August 05, 2016, 02:51:51 pm »
What's the code you're compiling?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Arunachalaeshwaran

  • Newbie
  • *
  • Posts: 4
  • I am a SFML noob
    • View Profile
Re: linking error while building a sfml project
« Reply #6 on: August 05, 2016, 03:10:35 pm »
my code:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.0);
    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;
}


also note I am using sfml version 2.3.2

 

anything