You are not logged in.
I am moving a project I have made, from one computer to another. they both have Arch installed on them. The new computer is a fresh installation, so I was going through and downloading the necessary packages. I got most of them, but then ran into this error.
fatal error: ft2build.h: No such file or directoryI have located the ft2build.h file in my /usr/include/freetype2 folder
I have tried reinstalling relevant packages, freetype2, gcc, etc
I have this sample code to demonstrate
#include <ft2build.h>
int main () {
return 0;
}which I compile with gcc. I have tried changing the include to <freetype2/ft2build.h>
which produces the error
freetype/config/ftheader.h: No such file or directoryso I looked and there is no /usr/include/freetype folder, but there is /usr/include/freetype2/freetype
On my old machine I do have /usr/include/freetype and its contents matched /usr/include/freetype2/freetype
so I copied the folder int othe directory above so now on my new computer i have /usr/include/freetype2
and /usr/include/freetype
and it compiles. But when I add a couple lines to the file (from my original project)
#include <freetype2/ft2build.h>
#include FT_FREETYPE_H
int main() {
FT_Library ft;
return 0;
}and now I get the error
/usr/include/freetype/freetype.h:32:10: fatal error: ft2build.h: No such file or directory
23 | #include <ft2build.h?so I am assuming there is a linker issue of some kind I must have missed something in my installation
I tried the command
gcc -xc -E -v -and got
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed
/usr/includeso gcc is looking in the right place, and this is the same on both computers.
Does anyone have any ideas of where to look? I am under the impression that freetype2 is sort of a basic library, I dont remember installing specially before. Is there some sort of development version or package I might be missing? Any help is much appreciated thank
TL;DR
How do you properly install freetype2 on Arch Linux for C development using gcc
Offline
There is no need to copy directories around.
It seems you are missing some compiler flags. Check out
pkg-configand
/usr/lib/pkgconfig/freetype2.pcOffline
There is no need to copy directories around.
It seems you are missing some compiler flags. Check out
pkg-configand
/usr/lib/pkgconfig/freetype2.pc
I understand that moving the directories didn't help.
maybe I am not understanding something you are saying, but as I explained the project works on my other computer, the compilation flags are all there.
/usr/lib/pkgconfig/freetype2.pc is there and I have the required dependencies. compiling with the flag
gcc main.c -lfreetypeproduces the same error as before.
fatal error: ft2build.h: No such file or directoryThe problem is the gcc cannot find the correct files at all. If gcc could initially find the files and then the library wasn't linked properly I would be getting undefined reference errors, not errors telling me the file doesn't exist
Offline
The flags are not all there, otherwise it would work.
Read about pkg-config. (Hint: look for the arguments --cflags and --libs.)
Offline
The flags are not all there, otherwise it would work.
Read about pkg-config. (Hint: look for the arguments --cflags and --libs.)
Ok thank you, you were right, I found a stackoverflow post that explained how to properly use pkg-config. Thanks for the help. And I got it to work by directly telling it where the directory is.
gcc -I/usr/include/freetype2 main.c But this is not necessary on my other computer, so I am wondering if I could have installed freetype incorrectly? Or did some installs in the wrong order perhaps.
/usr/include is in gcc's path directory, does it not check subdirectories?
also, copying ft2build.h from /usr/include/freetype2 into /usr/include also solved the problem without the need for telling gcc where to look.
Is that just some hacky thing I did months ago and forgot? Or is that possibly how freetype was installed previously and I messed up the installation
any thoughts are appreciated as I am just trying to understand more
thanks for reading
Offline
pacman -Ql freetype2CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline