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

Author Topic: Texture.loadFromFile("") error  (Read 1569 times)

0 Members and 1 Guest are viewing this topic.

pennywise881

  • Newbie
  • *
  • Posts: 1
    • View Profile
Texture.loadFromFile("") error
« 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

anthnich

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Long Division LLC
Re: Texture.loadFromFile("") error
« Reply #1 on: March 07, 2018, 04:37:36 pm »
Are your SFML libs linked to your project correctly?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Texture.loadFromFile("") error
« Reply #2 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything