ToxicNugget
Posts: 12
Joined: Fri Oct 19, 2018 3:47 pm

Configure unable to find FreeType2 library when compiling SDL2 TTF Library

Tue Aug 13, 2019 12:53 pm

I'm trying to compile SDL with hardware acceleration enabled.
All the other libraries I have compiled with it like SDL image, mixer, net, etc compile successfully however when I try and run configure for the TTF library it exits saying it's unable to find 'freetype-config' which is a deprecated script I'm pretty sure anyway and then below that states the error: "Unable to find FreeType2 library (http://www.freetype.org/)".
So I'm pretty stuck since I don't mess with C and C++ projects often and therefore I always get confused as to what the Makefiles are doing so can anybody tell me how I can fix this error?
temp.png
temp.png (19.54 KiB) Viewed 2142 times

User avatar
PeterO
Posts: 4942
Joined: Sun Jul 22, 2012 4:14 pm

Re: Configure unable to find FreeType2 library when compiling SDL2 TTF Library

Tue Aug 13, 2019 1:52 pm

Have you installed the freetype development package ?

I can't check on a PI right now, but my MINT box says....

Code: Select all

~$ dpkg -l | grep freetype
ii  libfreetype6:amd64                         2.8.1-2ubuntu2                              amd64        FreeType 2 font engine, shared library files
ii  libfreetype6-dev:amd64                     2.8.1-2ubuntu2                              amd64        FreeType 2 font engine, development files
[email protected]:~$ 
PeterO

I've fired up my Pi4....

Code: Select all

[email protected]:~ $ dpkg -l | grep freetype
ii  freetype2-doc                         2.9.1-3                               all          FreeType 2 font engine, development documentation
ii  libfreetype6:armhf                    2.9.1-3                               armhf        FreeType 2 font engine, shared library files
ii  libfreetype6-dev:armhf                2.9.1-3                               armhf        FreeType 2 font engine, development files
[email protected]:~ $ 
"sudo apt-get install libfreetype6-dev" should get you what you need....

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

ToxicNugget
Posts: 12
Joined: Fri Oct 19, 2018 3:47 pm

Re: Configure unable to find FreeType2 library when compiling SDL2 TTF Library

Tue Aug 13, 2019 2:16 pm

PeterO wrote:
Tue Aug 13, 2019 1:52 pm
Have you installed the freetype development package ?

I can't check on a PI right now, but my MINT box says....

Code: Select all

~$ dpkg -l | grep freetype
ii  libfreetype6:amd64                         2.8.1-2ubuntu2                              amd64        FreeType 2 font engine, shared library files
ii  libfreetype6-dev:amd64                     2.8.1-2ubuntu2                              amd64        FreeType 2 font engine, development files
[email protected]:~$ 
PeterO

I've fired up my Pi4....

Code: Select all

[email protected]:~ $ dpkg -l | grep freetype
ii  freetype2-doc                         2.9.1-3                               all          FreeType 2 font engine, development documentation
ii  libfreetype6:armhf                    2.9.1-3                               armhf        FreeType 2 font engine, shared library files
ii  libfreetype6-dev:armhf                2.9.1-3                               armhf        FreeType 2 font engine, development files
[email protected]:~ $ 
"sudo apt-get install libfreetype6-dev" should get you what you need....

PeterO
I've already tried installing this package and it says it's already the newest version. Any ideas?

User avatar
PeterO
Posts: 4942
Joined: Sun Jul 22, 2012 4:14 pm

Re: Configure unable to find FreeType2 library when compiling SDL2 TTF Library

Tue Aug 13, 2019 3:38 pm

You need to look at what is trying to use freetype-config and replace it with appropriate use of pkg-config to get the compiler options like this :

Code: Select all

[email protected]:~ $ pkg-config --cflags --libs freetype2
-I/usr/include/freetype2 -I/usr/include/libpng16 -lfreetype
[email protected]:~ $ 
From the first post it looks like you were running "./configure" when the error occurs ?

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

ToxicNugget
Posts: 12
Joined: Fri Oct 19, 2018 3:47 pm

Re: Configure unable to find FreeType2 library when compiling SDL2 TTF Library

Tue Aug 13, 2019 4:13 pm

PeterO wrote:
Tue Aug 13, 2019 3:38 pm
You need to look at what is trying to use freetype-config and replace it with appropriate use of pkg-config to get the compiler options like this :

Code: Select all

[email protected]:~ $ pkg-config --cflags --libs freetype2
-I/usr/include/freetype2 -I/usr/include/libpng16 -lfreetype
[email protected]:~ $ 
From the first post it looks like you were running "./configure" when the error occurs ?

PeterO
Ok so I tried replacing every instance of 'freetype-config' in the configure script to use 'pkg-config' and then under the lines that get cflags etc I added 'freetype2' at the end to match the syntax of pkg-config. Configure runs through completely fine this time however when I go to type make I get a ton of undefined reference errors like this: ./.libs/libSDL2_ttf.so: undefined reference to `hb_set_subtract'

These are the original lines before modification:
FREETYPE_CONFIG=$freetype_exec_prefix/bin/freetype-config
FREETYPE_CONFIG=$freetype_prefix/bin/freetype-config
CFLAGS="$CFLAGS `$FREETYPE_CONFIG $freetypeconf_args --cflags`"
LIBS="$LIBS `$FREETYPE_CONFIG $freetypeconf_args --libs`"

And these are them after:
FREETYPE_CONFIG=$freetype_exec_prefix/bin/pkg-config
FREETYPE_CONFIG=$freetype_prefix/bin/pkg-config
CFLAGS="$CFLAGS `$FREETYPE_CONFIG $freetypeconf_args --cflags freetype2`"
LIBS="$LIBS `$FREETYPE_CONFIG $freetypeconf_args --libs freetype2`"

This is the error that comes up:
temp.png
temp.png (50.54 KiB) Viewed 2099 times
I have also linked the backup (pre-modification) configure script and my modified one in an archive since I have not done this before so if there's anything you think I did wrong please let me know. :)
scripts.zip
(198.68 KiB) Downloaded 17 times

User avatar
PeterO
Posts: 4942
Joined: Sun Jul 22, 2012 4:14 pm

Re: Configure unable to find FreeType2 library when compiling SDL2 TTF Library

Wed Aug 14, 2019 8:26 am

looks like problems with harfbuzz and libpng not being linked. Do you have their "-dev" packages installed ?
There doesn't seem to be any mention of either of them in "configure" :?:

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

ToxicNugget
Posts: 12
Joined: Fri Oct 19, 2018 3:47 pm

Re: Configure unable to find FreeType2 library when compiling SDL2 TTF Library

Wed Aug 14, 2019 10:38 am

PeterO wrote:
Wed Aug 14, 2019 8:26 am
looks like problems with harfbuzz and libpng not being linked. Do you have their "-dev" packages installed ?
There doesn't seem to be any mention of either of them in "configure" :?:

PeterO
Thanks for all your help so far, after attempting to install them it says both libharfbuzz-dev and libpng-dev are both already installed and at the newest version.

User avatar
PeterO
Posts: 4942
Joined: Sun Jul 22, 2012 4:14 pm

Re: Configure unable to find FreeType2 library when compiling SDL2 TTF Library

Wed Aug 14, 2019 10:56 am

OK, it's odd that they are not mentioned in the configure script so it's hard to see how the appropriate libraries can be added to the linker options.
Is there any mention of libpng or harfbuzz in any of the make files that come out of the configure step ?

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

ToxicNugget
Posts: 12
Joined: Fri Oct 19, 2018 3:47 pm

Re: Configure unable to find FreeType2 library when compiling SDL2 TTF Library

Wed Aug 14, 2019 11:13 am

PeterO wrote:
Wed Aug 14, 2019 10:56 am
OK, it's odd that they are not mentioned in the configure script so it's hard to see how the appropriate libraries can be added to the linker options.
Is there any mention of libpng or harfbuzz in any of the make files that come out of the configure step ?

PeterO
In one of the Makefiles I found this line:
CFLAGS = -g -O2 -I/usr/local/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -D_REENTRANT -I/usr/local/include/SDL2 -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -DHAVE_OPENGL

I can find libpng16 and harfbuzz in these paths so they are there, there are no other mentions of 'libpng' or 'harfbuzz' anywhere else. There are a Makefile.am and Makefile.in which have no reference of the two so the standard Makefile is the only place referencing these libraries. I appreciate all your help and I've linked the Makefile below with the other two just in case I have missed anything.
makefiles.zip
(18.87 KiB) Downloaded 22 times

Return to “C/C++”