Include ft2build.h in project on Linux
Asked Answered
C

2

15

I've been trying to compile a JUCE project on Linux debian but a line is giving me an error:

#include <ft2build.h>

And stops compilation. How do I link to this file?

Corry answered 25/9, 2020 at 6:45 Comment(0)
C
16

So I've had this issue before and found the straight answer this time.

First, check if you have libfreetype installed. I used:

pkg-config --cflags freetype2

I do have the library installed, so I got this as a result:

-I/usr/include/freetype2 -I/usr/include/libpng16

If you don't have it installed, do:

sudo apt-get install libfreetype-dev libfreetype6 libfreetype6-dev

And try the first command again.

Then, link the header in your compilation. Using the ProJucer, this is easy, just paste /usr/include/freetype2 in the Header Search Paths in the settings section.

Corry answered 25/9, 2020 at 6:45 Comment(1)
Just a small note: /usr/include/freetype2 should be added (without the -I)Parkins
F
2

I know this is an old post but I've been at this problem for hours and hope I can help anyone facing the same issues.
(Note: I am using CMake and NeoVim on Pop!_OS)

After running pkg-config --cflags freetype2 as the comment above suggests, you have to add something like this in your CMakeLists.txt file
include_directories(/usr/include/freetype2 -I/usr/local/include/freetype2 -I/usr/include/libpng16
Also make sure to have the following lines:
find_package(Freetype)
target_link_libraries(project_name freetype)

At this point the code should compile, but in my case I was getting the same error message ('ft2build.h' file not found) in my IDE. This is fixed by adding set(CMAKE_EXPORT_COMPILE_COMMANDS ON) to the CMakeLists.txt file.
After that just call cmake --build . in your build folder and reopen your IDE.

Freytag answered 28/7 at 0:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.