Hello everyone,
I'm new to C++ and SFML. Although I've read the cplusplus.com language tutorial.
I'm trying to learn SFML and I wrote a basic program. However the compiler (GCC 4.7.2 on Linux X86_64) complains with a lot of "undefined reference to" errors. I suspected that it was not my code that was causing these errors, because I've checked everything. And I was right, because trying to compile the "graphics-shape.cpp"-example (downloaded from the sfml graphics package tutorial page) results in G++ giving similiar errors. These in fact:
/tmp/ccGhjJ4e.o: In function `main':
graphics-shape.cpp:(.text+0xa1): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, std::string const&, unsigned long, sf::WindowSettings const&)'
graphics-shape.cpp:(.text+0x11e): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x13e): undefined reference to `sf::RenderTarget::Clear(sf::Color const&)'
graphics-shape.cpp:(.text+0x162): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x178): undefined reference to `sf::Color::Red'
graphics-shape.cpp:(.text+0x1a8): undefined reference to `sf::Shape::Line(float, float, float, float, float, sf::Color const&, float, sf::Color const&)'
graphics-shape.cpp:(.text+0x1c8): undefined reference to `sf::RenderTarget::Draw(sf::Drawable const&)'
graphics-shape.cpp:(.text+0x1e3): undefined reference to `sf::Color::Blue'
graphics-shape.cpp:(.text+0x1f0): undefined reference to `sf::Color::Yellow'
graphics-shape.cpp:(.text+0x210): undefined reference to `sf::Shape::Circle(float, float, float, sf::Color const&, float, sf::Color const&)'
graphics-shape.cpp:(.text+0x230): undefined reference to `sf::RenderTarget::Draw(sf::Drawable const&)'
graphics-shape.cpp:(.text+0x263): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x279): undefined reference to `sf::Color::Green'
graphics-shape.cpp:(.text+0x2a1): undefined reference to `sf::Shape::Rectangle(float, float, float, float, sf::Color const&, float, sf::Color const&)'
graphics-shape.cpp:(.text+0x2c1): undefined reference to `sf::RenderTarget::Draw(sf::Drawable const&)'
graphics-shape.cpp:(.text+0x2df): undefined reference to `sf::Shape::Shape()'
graphics-shape.cpp:(.text+0x303): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x327): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x352): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x376): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x39a): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x3c5): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x3e9): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x40d): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x43d): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x45e): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x47f): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x4a4): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x4c5): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x4e6): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x510): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x531): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x552): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x577): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x58e): undefined reference to `sf::Shape::SetOutlineWidth(float)'
graphics-shape.cpp:(.text+0x5a2): undefined reference to `sf::Shape::EnableFill(bool)'
graphics-shape.cpp:(.text+0x5b6): undefined reference to `sf::Shape::EnableOutline(bool)'
graphics-shape.cpp:(.text+0x5d7): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x5ed): undefined reference to `sf::Drawable::SetColor(sf::Color const&)'
graphics-shape.cpp:(.text+0x60c): undefined reference to `sf::Drawable::Move(float, float)'
graphics-shape.cpp:(.text+0x62b): undefined reference to `sf::Drawable::Scale(float, float)'
graphics-shape.cpp:(.text+0x642): undefined reference to `sf::Drawable::Rotate(float)'
graphics-shape.cpp:(.text+0x662): undefined reference to `sf::RenderTarget::Draw(sf::Drawable const&)'
graphics-shape.cpp:(.text+0x6ab): undefined reference to `sf::RenderWindow::~RenderWindow()'
graphics-shape.cpp:(.text+0x6dd): undefined reference to `sf::RenderWindow::~RenderWindow()'
graphics-shape.cpp:(.text+0x7a4): undefined reference to `sf::RenderWindow::~RenderWindow()'
/tmp/ccGhjJ4e.o: In function `sf::Shape::~Shape()':
graphics-shape.cpp:(.text._ZN2sf5ShapeD2Ev[_ZN2sf5ShapeD5Ev]+0x14): undefined reference to `vtable for sf::Shape'
graphics-shape.cpp:(.text._ZN2sf5ShapeD2Ev[_ZN2sf5ShapeD5Ev]+0x32): undefined reference to `sf::Drawable::~Drawable()'
graphics-shape.cpp:(.text._ZN2sf5ShapeD2Ev[_ZN2sf5ShapeD5Ev]+0x5b): undefined reference to `sf::Drawable::~Drawable()'
collect2: error: ld returned 1 exit status
So either the problem is being caused by my system/setup or there's some bug in SFML 1.6 (highly unlikely, because a lot of people should've tried to compile the graphics-shape.cpp example)
Kind regards,
Superpelican