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

Author Topic: Undefined reference from loadFromFile  (Read 3695 times)

0 Members and 2 Guests are viewing this topic.

zedong

  • Newbie
  • *
  • Posts: 3
    • View Profile
Undefined reference from loadFromFile
« on: December 14, 2016, 12:35:01 pm »
Hello, I just recently tried to compile my project as a windows .exe.

Linking the sfml lib worked fine, and the test project from the tutorial page worked fine, however, when I try to compile my project, it complains about every single loadFromFile is undefined.

Using gcc 9.4.2 with SFML 2.4.2 in Code::Blocks.

The message I get is:
C:\Users\Kristian\Desktop\project\vk\Menu.cc|202|undefined reference to `sf::Texture::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Rect<int> const&)'|

Thanks in advance.

Edit: It compiles just fine if I comment out every single loadFromFile, but obviously that just leaves me with a blank window.
« Last Edit: December 14, 2016, 12:36:49 pm by zedong »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11006
    • View Profile
    • development blog
    • Email
Undefined reference from loadFromFile
« Reply #1 on: December 14, 2016, 12:51:39 pm »
You're probably using a different compiler than the one that was used to compile the SFML binaries. The compilers need to match 100%.
Either build SFML yourself with your compiler (it's easy!) or check the download page to see which compilers have been used for the provided binaries.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zedong

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Undefined reference from loadFromFile
« Reply #2 on: December 14, 2016, 01:00:36 pm »
Using the gcc TDM 4.9.2 linked from http://www.sfml-dev.org/download/sfml/2.4.1/.


victorlevasseur

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: Undefined reference from loadFromFile
« Reply #3 on: December 14, 2016, 01:46:11 pm »
Maybe you build your project with C++11 but SFML is not built with C++11 (there have been a change in the ABI of the GCC standard lib with C++11).

zedong

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Undefined reference from loadFromFile
« Reply #4 on: December 14, 2016, 02:07:18 pm »
I've tried both with and without -std=c++11 with the same result unfortunaly.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11006
    • View Profile
    • development blog
    • Email
Re: Undefined reference from loadFromFile
« Reply #5 on: December 14, 2016, 03:33:25 pm »
Make sure the actual build command doesn't contain a -std=c++11 anymore. Sometimes these settings are rather hidden.

Otherwise try to rebuild SFML with -std=c++11.

Or alternatively update your compiler to another one listed on the download page and get the respective binaries.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything