-1

When I use the function .loadFromFile(), i get the following error:

undefined reference to `sf::Texture::loadFromFile(std::__cxx11::basic_string, std::allocator > const&, sf::Rect const&)'|

I have already tried different versions of SFML, and according to their website I'm using the correct one.

Here is my setup: codeblocks-17.12mingw-setup.exe => download for codeblocks SFML-2.4.2-windows-gcc-4.9.2-tdm-32-bit => SFML I am using

Here are my settings: enter image description here

enter image description here

enter image description here

in the compiler tab

enter image description here

in the linker tab

enter image description here

The linking should be ok, as all the other SFML functions work. I have read that it could be because of SFML being compiled by a different compiler than mine? How can I check that? Is it something else that causes this problem?

here is the code :

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>

using namespace sf;

int main () {

Texture texun;
    texun.loadFromFile("C:\\Users\\j_hyl\\OneDrive\\Bureaublad\\Webdev\Apps\\Drive\\sprite.bmp");

return 0;
}

pevhv
  • 58
  • 7
  • 1
    https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Texture.php says the `sf::Texture` is part of the `graphics` module, do you link to that? – Zaiborg Jul 23 '19 at 11:52
  • yes. You can't see it on the picture but yes i linked to it. I can use RectangleShape and it's methods for example, without any problem – pevhv Jul 23 '19 at 12:40
  • 1
    As stated in https://stackoverflow.com/questions/28994820/issue-with-linking-order-of-the-libraries the order of the linker input matters, can you try to move the graphics module down in the linker arguments? – Zaiborg Jul 23 '19 at 12:46
  • Figured it out! Wrong SFML version (using 2.4.2 instead of 2.5.1). Thx for the help! – pevhv Jul 23 '19 at 12:55

1 Answers1

2

you have to link to sfml-graphics.lib or if your configuration is debug you have to link with sfml-graphics-d.lib and you have to copy the sfml-graphics-2.dll and sfml-graphics-d-2.dll(if debugging conf.) to the folder where your executable is

thakee nathees
  • 877
  • 1
  • 9
  • 16