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

Author Topic: Using sf::Text and sf::Font in Windows ×64 MinGW  (Read 985 times)

0 Members and 1 Guest are viewing this topic.

intweek

  • Newbie
  • *
  • Posts: 2
    • View Profile
Using sf::Text and sf::Font in Windows ×64 MinGW
« on: May 30, 2023, 09:31:18 pm »
Hello everyone,
I tried using sf::Text (or any other text related thing), but whenever I do so, I get a lot of errors, which all look like:

"Font.cpp:(.text+0x3178): undefined reference to `FT_Get_Char_Index"

What am I doing wrong?

NOTE: I am using VS code, windows 11, SFML is staticaly linked.

Thrasher

  • SFML Team
  • Jr. Member
  • *****
  • Posts: 53
    • View Profile
Re: Using sf::Text and sf::Font in Windows ×64 MinGW
« Reply #1 on: May 30, 2023, 09:49:49 pm »
https://github.com/SFML/SFML#community

If you come over to the Discord server you can get some help on this. There's a number of potential reasons you have linker errors

kimci86

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Using sf::Text and sf::Font in Windows ×64 MinGW
« Reply #2 on: May 30, 2023, 10:59:21 pm »
The linker error tells FreeType is not linked.
If you link SFML statically, then you need to link its dependencies too. FreeType is one of the dependencies.

See the list of dependencies for each SFML module here: https://www.sfml-dev.org/faq.php#build-link-static
They are also listed in this tutorial: https://www.sfml-dev.org/tutorials/2.5/start-vc.php

intweek

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Using sf::Text and sf::Font in Windows ×64 MinGW
« Reply #3 on: May 31, 2023, 06:02:09 am »
The linker error tells FreeType is not linked.
If you link SFML statically, then you need to link its dependencies too. FreeType is one of the dependencies.

See the list of dependencies for each SFML module here: https://www.sfml-dev.org/faq.php#build-link-static
They are also listed in this tutorial: https://www.sfml-dev.org/tutorials/2.5/start-vc.php

So if I linked dynamically, I wouldn't need to do anything regarding downloading/linking freetype?

The question becomes, should I even link staticaly?

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Using sf::Text and sf::Font in Windows ×64 MinGW
« Reply #4 on: May 31, 2023, 05:52:10 pm »
If linking dynamically, you don't need to manually link freetype, no.

You shouldn't need to download them either way; they're provided alongside SFML in SFML/extlibs.

Whether you should or not is a matter of taste/style, productivity and portability.
With dynamic linking you need to ship the (very few) SFML files with your executable. This is the easiest way, I'd say.
With static linking, the SFML stuff is stuffed inside your executable making it a fewer files, possibly reducing the number of files in your app by about 5.. :-X
But, with static linking, there are extra things you need to link and setup (defining SFML_STATIC, for example) so can cause some confusion sometimes.
Also, if you use the audio module, the OpenAL file must be shipped with your app regardless of whether it is dynamic or static.

If you're going to be providing one library file, why not (up to) 6 more ;D?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

kojack

  • Sr. Member
  • ****
  • Posts: 314
  • C++/C# game dev teacher.
    • View Profile
Re: Using sf::Text and sf::Font in Windows ×64 MinGW
« Reply #5 on: June 01, 2023, 03:25:58 am »
Space can be a factor too.
When a static library is linked, the linker can see which parts are being used, so it only merges those into your final executable.
When a dynamic library is linked, the linker doesn't know who will load it at runtime, so it must include everything.
This means a static link results in a slightly bigger executable than dynamic, but no dlls with unneeded stuff, so overall static will be smaller.

On the other hand, if you have several executables in your project (maybe a game, an editor, a config program, etc) that all use the same library, static linking means every one of them has to include the parts they need, while dynamic linking lets them all share the same dll. So dynamic might have a saving there.

 

anything