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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Negawisp

Pages: [1]
1
Graphics / Re: Undefined refference to sf::Texture::loadFromFile
« on: April 06, 2018, 07:17:07 pm »
It's never about the IDE, it's always about the compiler the IDE uses.

So where did you get SFML from? What OS are you using?
If that version wasn't built with the exact same compiler that you use, it might not work.

You shouldn't define SFML_STATIC in your code and you shouldn't define SFML_STATIC at all if you're not linking SFML statically.

I got it with sudo apt-get install libsfml-dev. I am using lubuntu. I got your point with SFML_STATIC, thank you.
While waiting for response I will now try to build new version with up-to-date tools :)

2
Graphics / Re: Undefined refference to sf::Texture::loadFromFile
« on: April 06, 2018, 12:27:52 pm »
The code itself:
#define SFML_STATIC

#include <SFML/Graphics.hpp>
//#include <SFML/Audio.hpp>

#define WASSERT() printf ("Error in file %s, functon %s, on line %d.", \
                          __FILE__, __PRETTY_FUNCTION__, __LINE__);


int main ()
{
        sf::RenderWindow window (sf::VideoMode (200, 200), "Hello!");
        system ("say 2");

        //sf::IntRect rectangle (0, 0, 200, 200);
        sf::Rect<int> rectangle1 (0, 0, 200, 200);

        sf::Texture hello_texture;
        hello_texture.loadFromFile ("hello-world.jpg", rectangle1) || WASSERT ();

        sf::Sprite hello_sprite;
        hello_sprite.setTexture (hello_texture);

        //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();
                }
                if (sf::Keyboard::isKeyPressed (sf::Keyboard::Escape))
                        break;

                window.clear ();
                window.draw (hello_sprite);
                //window.draw (shape);
                window.display ();
        }

        return 0;
}
 

3
Graphics / Undefined refference to sf::Texture::loadFromFile
« on: April 06, 2018, 12:00:13 pm »
Having compiled a small program using g++-4.8
g++-4.8 -c main.cpp
and trying to link it with SFML files, using g++-4.8 as well,
g++-4.8 -o main.o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
I've encountered such problem:
main.cpp:(.text+0x234): undefined reference to `sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'

I've already checked another topic, and the key to the problem was rebuilding SFML so that the IDE and the up-to-date compiler could use it properly. But I feel like that might not work in my case, as I do not use IDE. What are the other possible precursors to this problem?

Pages: [1]