SFML community forums
Help => General => Topic started by: djninjamaster13 on January 29, 2018, 02:06:36 pm
-
Hey Guys, newbie here.
From the start, I would like to acknowledge that I know there are other posts that had this problem, but I couldn't figure out how to fix it with any of the solutions from those posts. I am using Code::Blocks 17.12 on Windows 10 with the TDM 4.9.2 (32 bit) compiler and SFML version 2.4.2. I am trying to incorporate a texture to use with a sprite, but I get an error code every time.
My code (the lines that produce the error):
sf::Texture texture;
if (!texture.loadFromFile("")) {
cout << "ERROR LOADING TEXTURE!!!!!" << endl;
}
Error Code:
||=== Build: Debug in CompScience-2 (compiler: TDM Compiler17) ===|
obj\Debug\game.o||In function `main':|
C:\Users\djnin\Documents\CompScience-2\game.cpp|10|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), 0 second(s)) ===|
Most posts suggested changing the compiler to match SFML, but I switched from my original GNU GCC Compiler to the TDM 4.9.2 from the SFML website and nothing changed. Should I try a different compiler or did I most likely install the TDM one incorrectly? Thanks in advance!
-
I can't remember if that was the solution, but afaik SFML wasn't built with C++11 active, so when you set it active in your project, then there might be some ABI mismatch for std::string.
The best solution is to simply rebuild SFML with whatever compiler you want to use.
While you're at it picking compilers and building SFML on your own, might I suggest taken a MinGW Builds build (https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.2.0/threads-posix/seh/) as they are very recent (GCC 7.2.0) and I've pretty much never ran into issues otherwise (compared to TDM builds).