SFML community forums

Help => Graphics => Topic started by: pennywise881 on March 07, 2018, 11:44:27 am

Title: Texture.loadFromFile("") error
Post by: pennywise881 on March 07, 2018, 11:44:27 am
Hi there, i cant make a sprite sheet appear on my game screen. I am using codeblocks as my IDE and the way I am trying to achieve it is by doing this:
int main()
{
    gameWindow.create(sf::VideoMode(1000,800),"My Game",sf::Style::Titlebar | sf::Style::Close);
    sf::Texture pTexture;
    sf::Sprite playerImage;
    pTexture.loadFromFile("Player.png");//this is where i am getting the error
    playerImage.setTexture(pTexture);

    while(gameWindow.isOpen())
    {
        while(gameWindow.pollEvent(event))
        {
            if(event.type==sf::Event::Closed)gameWindow.close();
        }

        gameWindow.draw(playerImage);
        gameWindow.display();
    }
}
the error in the logs is this : "undefined reference to `_imp___ZN2sf7Texture12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_4RectIiEE'"

Any help is appreciated
Title: Re: Texture.loadFromFile("") error
Post by: anthnich on March 07, 2018, 04:37:36 pm
Are your SFML libs linked to your project correctly?
Title: Re: Texture.loadFromFile("") error
Post by: eXpl0it3r on March 07, 2018, 05:03:50 pm
Are you using the latest Code::Blocks version, but using the old pre-built libraries that you downloaded from our website?

If so, these compilers aren't compatible.