I build a simple glfw, glad project on vs code successfully. My issue is. I add <freetype2/ft2build.h> header to my project and I do those commands in my project folder:
sudo su
cd build
cmake ..
makenormally that works without error.
I get error called:
In file included from /home/gomi/Documents/ubuntuProject/main.c:3: /usr/include/freetype2/ft2build.h:39:10: fatal error: freetype/config/ftheader.h: No such file or directory 39 | #include <freetype/config/ftheader.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~compilation terminated.I went to usr/include/freetype2 path from terminal. If I remember correctly I seen only ft2build.h in directory no other config folder. I downloaded freetype2 files and I copied freetype folder to this directory and I got same error. In the end of I deleted copied freetype folder. I am not sure if they were already there and I damaged freetype2.
What I should do ?
42 Answers
As I stated, you shouldn't be running cmake and make as root but that appears to be a different issue.
As for your problem, first delete the file you added manually. Then, you can install the following package to fix the issue:
sudo apt update
sudo apt install --reinstall libfreetype6-devYou can locate files like this using the apt-file command.
sudo apt update
sudo apt install apt-file
sudo apt-file update
apt-file search ftheader.hThis will return which package contains the file you need.
0After searching for hours. I think I found it. First, that tries to search it in wrong directory unless you tell it to cmake.
I found it on this page :
I just added to vs code's include directories
/usr/include/freetype2I put header
#include <ft2build.h>andFT_FREETYPE_Hjust after it, to mymain.cfile.I used
pkg-config --cflags freetype2command to ensure its location-I/usr/include/freetype2I went to
CMakeLists.txtfile then I addedinclude_directories (/usr/include/freetype2)line. Final CMakeLists.txt file looks like this:cmake_minimum_required(VERSION 3.20.3) project(gomi) include_directories (/usr/include/freetype2) add_executable(${PROJECT_NAME} glad.c main.c) target_link_libraries(${PROJECT_NAME} GL dl glfw)My commands to re-build it:
cd ../ # one path pack from build folder) rm -r build/* # delete all files in build) cd build cmake .. make ./myprogramname # runs