Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Font library not being linked to mingw  (Read 1686 times)

0 Members and 1 Guest are viewing this topic.

Aiden_Cohen

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Font library not being linked to mingw
« on: March 18, 2018, 01:55:27 am »
Setup
Mingw
Windows 10

Problem
Error undefined reference to `_imp___ZN2sf4Font12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
Can't figure out the problem because the .ttf file is in the folder that the program i'm compiling is in.

Command I used
g++ main.cpp -IC:\Development\SFML-2.3.1\include -LC:\Development\SFML-2.3.1\lib -lsfml-graphics -lsfml-window -lsfml-system -o a.exe

Code
#include <SFML/Graphics.hpp>
#include <iostream>
//#include "intro.h"

int main()
{
   sf::RenderWindow Window(sf::VideoMode::getDesktopMode(),"Hello Window");
   
   sf::Font font;
   if(!font.loadFromFile("bit.ttf"))
   {
       std::cout << "No Work";
   }
   
   sf::Text text("hello", font);
   text.setCharacterSize(30);
   text.setStyle(sf::Text::Bold);
   text.setColor(sf::Color::Red);
   
    while(Window.isOpen())
    {
     
      sf::Event Event;
      while(Window.pollEvent(Event))
      {

          if(Event.type == sf::Event::Closed)
          {

              Window.close();
          }

      }

      // Declare and load a font


// Create a text

// Draw it
      Window.draw(text);
      Window.clear(sf::Color());
      Window.display();
    }
}
 
« Last Edit: March 22, 2018, 01:36:35 am by Aiden_Cohen »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Font not being loaded by compiler
« Reply #1 on: March 19, 2018, 09:14:33 am »
The compiler doesn't load the font, it simply fails to compile.

If you use the latest Code::Blocks version, you need to build SFML yourself, as the compiler doesn't match the one used for official downloads.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/