Hi, I am new to C++ and have recently started to study SFML too. After I've followed all the steps in order to create a dynamically linked SFML project on Code::Blocks, I was able to make some basic coding such as creating a window, printing shapes, using user imput to move shapes, etc. but when I tried to put some text on the screen I got the error message:
"C:\CPP\IntroductionSFML\main.cpp|10|undefined reference to `_imp___ZN2sf4Font12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE|".
The line to which it reffers is this:
font.loadFromFile("arial.ttf");
Here is the code I'm trying to compile (I reduced it to the minimum, but at first I was trying to use text in a bigger code):
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Application");
sf::Font font;
font.loadFromFile("arial.ttf");
sf::Text text("Hello!", font, 30);
text.setPosition(50,50);
text.setColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(text);
window.display();
}
}
I think this problem is not related to the directory where I've put the font file, because when I tried to run the following code, I've got the exactly same message.
if (!font.loadFromFile("arial.ttf"))
{
// error...
}
As I said before, SFML worked perfectly well when I was using other resources, such as shapes, window, events, keyboard, etc.
Please, could you help me finding out what is the problem?