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

Author Topic: Linker error with libfreetype [SOLVED]  (Read 1233 times)

0 Members and 1 Guest are viewing this topic.

daywithstars

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Linker error with libfreetype [SOLVED]
« on: March 10, 2023, 08:35:58 pm »
I'm having some trouble when trying to compile the source code using cmake. I'm on Unbuntu 22.04 amd64, and when it tries to link the libsfml-graphics.so I get this error message:

Consolidate compiler generated dependencies of target sfml-system
[ 16%] Built target sfml-system
Consolidate compiler generated dependencies of target sfml-window
[ 41%] Built target sfml-window
Consolidate compiler generated dependencies of target sfml-network
[ 51%] Built target sfml-network
Consolidate compiler generated dependencies of target sfml-graphics

[ 52%] Linking CXX shared library ../../../lib/libsfml-graphics-d.so
/usr/bin/ld: /usr/local/lib/libfreetype.a(ftstroke.c.o): warning: relocation against `ft_outline_glyph_class' in read-only section `.text'
/usr/bin/ld: /usr/local/lib/libfreetype.a(ftglyph.c.o): relocation R_X86_64_PC32 against symbol `ft_bitmap_glyph_class' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/build.make:584: lib/libsfml-graphics-d.so.2.5.1] Error 1
make[1]: *** [CMakeFiles/Makefile2:264: src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

As you can see the other modules build fine.
« Last Edit: March 11, 2023, 08:21:27 pm by daywithstars »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10825
    • View Profile
    • development blog
    • Email
Re: Linker error with libfreetype
« Reply #1 on: March 11, 2023, 10:39:32 am »
How did you get freetype? It looks like a static library, did you build it yourself?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

daywithstars

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Linker error with libfreetype
« Reply #2 on: March 11, 2023, 02:56:47 pm »
How did you get freetype? It looks like a static library, did you build it yourself?

I've downloaded it at: https://www.sfml-dev.org/download/sfml/2.5.1/

This is the stable version, scroll down it says: All | source code

1. I create a folder in the root dir called: DEBUG
2. I enter that folder with the terminal.
3. Then call: cmake -DCMAKE_BUILD_TYPE=Debug ..
4. Then: make

Where I get those message errors when it tries to compile the sfml-graphics-d module. In the source code there is a folder called 'extlibs' but I think is for OS Windows, maybe somehow it compiles some static libraries from that? or uses it!? Because previously I've tried to build statically and it works, then I installed with 'make install'.
« Last Edit: March 11, 2023, 03:01:43 pm by daywithstars »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10825
    • View Profile
    • development blog
    • Email
Re: Linker error with libfreetype
« Reply #3 on: March 11, 2023, 03:44:36 pm »
SFML doesn't ship binaries for Linux, as such you won't have gotten those file from SFML itself.

Either way, I recommend to just install libfreetype-dev or whatever the freetype development package is called in your distro's package manager, which should then install a system-compatible version.
Then clear the CMake cache a build SFML fresh and I guess make sure, CMake isn't picking up the rogue freetype library.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

daywithstars

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Linker error with libfreetype
« Reply #4 on: March 11, 2023, 08:19:27 pm »
Solved.

I simply remove manually this 'libfreetype.a' file from '/usr/local/lib' and do this basic process of compiling with cmake as I've described above. My system already has the 'libfreetype-dev'.

I don't know how it appears but, that is it.

Thanks for your attention eXpl0it3r.
« Last Edit: March 11, 2023, 08:24:53 pm by daywithstars »