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

Author Topic: Undefined reference sf::Texture::loadFromFile  (Read 5857 times)

0 Members and 1 Guest are viewing this topic.

Pzc

  • Newbie
  • *
  • Posts: 2
    • View Profile
Undefined reference sf::Texture::loadFromFile
« on: February 12, 2016, 09:44:09 pm »
Hello there !

I've just recently tried SFML and have bumped into a little
of a problem. SFML is working fine with simple programs
and there's no problem creating a CircleShape and moving
it around with the keyboard using events.

When I tried replacing CircleShape with Sprite and Texture
this line:
if(!PlayerTexture.loadFromFile("res/player.png"))
makes the linker complain as such:
Quote
||=== Build: Release in sfmltst01 (compiler: GNU GCC Compiler) ===|
obj\Release\sfmltst01.o:sfmltst01.cpp|| undefined reference to `sf::Texture::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Rect<int> const&)'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|

I did look at the tutorial page (http://www.sfml-dev.org/tutorials/2.3/start-cb.php)
and set up to linking the SFML libraries statically (SFML_STATIC is defined):
(click to show/hide)

I've tried messing with the linking order and #including
a bunch of files but I've not managed to solve it.

Using Code::Blocks 16.01 with TDM-GCC 5.1.0-3 and
SFML 2.3.2 GCC 4.8.1 TDM (SJLJ) - 32-bit on Windows.

Any help for what probably is just a beginners error
is greatly appreciated, thanks for reading =)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Undefined reference sf::Texture::loadFromFile
« Reply #1 on: February 13, 2016, 03:09:01 pm »
Using Code::Blocks 16.01 with TDM-GCC 5.1.0-3 and
SFML 2.3.2 GCC 4.8.1 TDM (SJLJ) - 32-bit on Windows.
Would have hoped that this became apparent as soon as you typed that, but the SFML package you try to use has not been compiled with the same compiler you use, thus making them incompatible.
At best you just build SFML from source with your compiler.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Pzc

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Undefined reference sf::Texture::loadFromFile
« Reply #2 on: February 13, 2016, 03:46:52 pm »
Would have hoped that this became apparent as soon as you typed that, but the SFML package you try to use has not been compiled with the same compiler you use, thus making them incompatible.
At best you just build SFML from source with your compiler.
I didn't think there would've been any difference as
long as I stuck with SJLJ and not the DW2 package.

I guess I was just lucky anything worked at all then.
Downgrading the compiler suite seems to be the
easier way out, not in need of anything super fancy.

Thanks for the reply =)

 

anything