Hi. I want to create a basic texture in SFML, Code::Blocks, but I am still receiving an extremly annoying and weird error:
C:\Users\user\Desktop\Wow\main.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|.
I looked for a reliable code from a tutorial, but this error still keeps occuring.
This is the code:
#include "SFML/Graphics.hpp"
#include <iostream>
int main()
{
sf::RenderWindow window( sf::VideoMode( 600, 600 ), "SFML WORK!" );
sf::Texture texture;
if (!texture.loadFromFile("simplypears.jpg"))
{
std::cout << "Error loading paddle texture :(" << std::endl;
}
//sf::Sprite sprite(texture);
// or
sf::Sprite sprite;
sprite.setTexture(texture);
while ( window.isOpen( ) )
{
sf::Event event;
while ( window.pollEvent( event ) )
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
}
}
window.clear( );
window.draw(sprite);
window.display( );
}
}
I really want to learn SFML and create cool things, but this exasperating error stops me.
So please help me!