SFML community forums
Help => Graphics => Topic started by: Arunachalaeshwaran 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 (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.
-
And what's your build command?
-
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.
-
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
-
I just ran that now and it shows the same error as before.
-
What's the code you're compiling?
-
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