SFML community forums
Help => Graphics => Topic started by: Helik on August 26, 2017, 07:12:00 pm
-
Hello there!
I use IDE CodeLite and wrote the following code:
#include <SFML/Graphics.hpp>
using namespace sf;
int main()
{
RenderWindow window(VideoMode(550, 200), "test");
Texture t;
t.loadFromFile("images\hero.png");
Sprite s;
s.setTexture(t);
s.setPosition(50 , 25);
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
window.clear();
window.draw(s);
window.display();
}
return 0;
}
And when i click "Run" enter goes error:
F:/MyProject/SFML/First/main.cpp:8: undefined reference to `sf::Texture::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Rect<int> const&)'
What's wrong?
I was looking for an explanation, but I couldn't find
The program was set up as stated here: https://en.sfml-dev.org/forums/index.php?topic=18820.0
When i use code, how here: https://www.sfml-dev.org/tutorials/2.4/start-cb.php it worked
If need something to add, I'll do ;D
-
It looks like you're mixing up builds.
It seems to be building in Debug mode whereas you are linking to release builds of SFML.
It seems that you have defined "SFML_STATIC" but are not linking to static builds of SFML.
If you are building statically, you also need to link the modules' dependencies.
You mentioned this tutorial; this information is all there ;)
https://www.sfml-dev.org/tutorials/2.4/start-cb.php#creating-and-configuring-a-sfml-project