SFML community forums

Help => Graphics => Topic started by: zedong on December 14, 2016, 12:35:01 pm

Title: Undefined reference from loadFromFile
Post by: zedong 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.
Title: Undefined reference from loadFromFile
Post by: eXpl0it3r 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.
Title: Re: Undefined reference from loadFromFile
Post by: zedong 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/.

Title: Re: Undefined reference from loadFromFile
Post by: victorlevasseur 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).
Title: Re: Undefined reference from loadFromFile
Post by: zedong on December 14, 2016, 02:07:18 pm
I've tried both with and without -std=c++11 with the same result unfortunaly.
Title: Re: Undefined reference from loadFromFile
Post by: eXpl0it3r 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.