Hej !
I'm just working on a new project in SFML on Archlinux and everything went well, until I tried to load a Font. I don't really understanf why i get that error.
HW_Ressource.h
#ifndef HW_RESSOURCES_H
#define HW_RESSOURCES_H
#include <SFML/Graphics.hpp>
class HW_Ressources
{
private:
HW_Ressources();
static sf::Font font_cantarell;
public:
static void load();
static const sf::Font get_font_cantarell();
};
#endif
HW_Ressources.cpp
#include "HW_Ressources.h"
void HW_Ressources::load()
{
sf::Font font;
if(!font.loadFromFile("Cantarell-Regular.otf"))
exit(EXIT_FAILURE);
else HW_Ressources::font_cantarell = sf::Font(font);
}
const sf::Font HW_Ressources::get_font_cantarell()
{
return HW_Ressources::font_cantarell;
}
COMPILING:
g++ -std=gnu++11 -Wall -Werror *.cpp -o exe -lsfml-graphics -lsfml-window -lsfml-system ; ./exe
/usr/bin/ld: /tmp/cciPHgtd.o: warning: relocation against `_ZN13HW_Ressources14font_cantarellE' in read-only section `.text'
/usr/bin/ld: /tmp/cciPHgtd.o: in function `HW_Ressources::load()':
HW_Ressources.cpp:(.text+0xc6): undefined reference to `HW_Ressources::font_cantarell'
/usr/bin/ld: /tmp/cciPHgtd.o: in function `HW_Ressources::get_font_cantarell()':
HW_Ressources.cpp:(.text+0x177): undefined reference to `HW_Ressources::font_cantarell'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
zsh: no such file or directory: ./exe