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

Author Topic: Symbol Has Different Size?  (Read 1440 times)

0 Members and 1 Guest are viewing this topic.

Samidamaru

  • Newbie
  • *
  • Posts: 3
    • View Profile
Symbol Has Different Size?
« 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:

Code: [Select]
#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
Code: [Select]
g++ sfml.cpp -o sfml-app -L/usr/lib -lsfml-graphics -lsfml-window -lsfml-system
but this gave lots of undefined reference errors:
Code: [Select]
/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:
Code: [Select]
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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Symbol Has Different Size?
« Reply #1 on: November 13, 2014, 11:51:32 pm »
It's best if you just rebuild SFML from source.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Samidamaru

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Symbol Has Different Size?
« Reply #2 on: November 14, 2014, 12:30:17 am »
Okay, so reinstall it now I've deleted the old libraries?

Out of curiosity, why do I have to specify the -L /usr/lib tag and -ludev, I haven't seen those in any other code. As a linux build, shouldn't it check /usr/lib by default or do I need to install it somewhere else too ? (I'm running 64 bit if that makes a difference)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Symbol Has Different Size?
« Reply #3 on: November 14, 2014, 06:56:40 am »
Did you grab the latest source code from GitHub and build that? The udev "detection" has been fixed just a few days ago.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Samidamaru

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Symbol Has Different Size?
« Reply #4 on: November 14, 2014, 05:13:34 pm »
So I grabbed the 2.1 version from the downloads page here. I suppose that isn't the same as the version on github.

My "different size" issues has gone away as has my need to use -L but I still have to -ludev.

Could I be a bit of a pest and ask how I go about building it from the github version? All of the tutorials I've found involve using windows and installing it in a non-standard directory.

Thanks for your help!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Symbol Has Different Size?
« Reply #5 on: November 14, 2014, 05:58:43 pm »
Yes, the 2.1 version from the download page is well version 2.1 and not the latest development version.

Check the official tutorial.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/