3
« on: November 13, 2014, 09:58:59 pm »
Hello there, I've been struggling to get SFML working for a little while now.
I have installed SFML 2.0 on OpenSUSE 13.1
I tried this simple test code:
#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;
}
I tried to compile with
g++ sfml.cpp -o sfml-app -L/usr/lib -lsfml-graphics -lsfml-window -lsfml-system
but this gave lots of undefined reference errors:
/tmp/ccAD24QA.o: In function `main':
sfml.cpp:(.text+0xeb): undefined reference to `sf::String::String(char const*, std::locale const&)'
sfml.cpp:(.text+0x12d): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
sfml.cpp:(.text+0x161): undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
sfml.cpp:(.text+0x175): undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
sfml.cpp:(.text+0x195): undefined reference to `sf::Window::close()'
sfml.cpp:(.text+0x1ae): undefined reference to `sf::Window::pollEvent(sf::Event&)'
sfml.cpp:(.text+0x1ed): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
sfml.cpp:(.text+0x204): undefined reference to `sf::RenderStates::Default'
sfml.cpp:(.text+0x20f): undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
sfml.cpp:(.text+0x21e): undefined reference to `sf::Window::display()'
sfml.cpp:(.text+0x22d): undefined reference to `sf::Window::isOpen() const'
/tmp/ccAD24QA.o: In function `sf::CircleShape::~CircleShape()':
sfml.cpp:(.text._ZN2sf11CircleShapeD2Ev[_ZN2sf11CircleShapeD5Ev]+0x13): undefined reference to `vtable for sf::CircleShape'
sfml.cpp:(.text._ZN2sf11CircleShapeD2Ev[_ZN2sf11CircleShapeD5Ev]+0x1f): undefined reference to `vtable for sf::CircleShape'
collect2: error: ld returned 1 exit status
So I added -ludev and it compiled fine, but now when it runs I get this error:
Symbol `_ZN2sf12RenderStates7DefaultE' has different size in shared object, consider re-linking
I have already tried removing libsfml1_6 and sfml-devel using zypper remove but this doesn't seem to fix the problem and I have no idea what to do or how to "relink" the executables.
Any help?