i am an embedded developer and quite new to the Linux world.
my task is to write a fairly simple driver which i am to understand the need for linux-kernel modules .
i do have a simple c file which iam trying to compile but with no success yet
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/ioport.h>
void main (void)
{
printf("Hi There ! \n");
}
i get the error init.h
and ioport.h
files are not found
the compatible version of linux-header is now installed on my pc using apt pm.
these files are not in usr/include/linux
but they are stored in usr/src/linux-headers-5.4.19-91/include
.
so i tried to add the path of usr/src/linux-headers-5.4.19-91/include
using export PATH – didnt work
tried to use the makefile inside usr/src/linux-headers-5.4.19-91/
hoping that it would be installed next but i am getting no rule to make target arch/x86/tools/relocs_32.c
and now i am trying to include this path to my CMake file (rn i am noob in cmake) using this code :
target_include_directories (driver PUBLIC usr/src/linux-headers-5.4.19-91/include)
target_include_directories (driver PUBLIC usr/src/linux-headers-5.4.19-91/include/config)
target_include_directories (driver PUBLIC usr/src/linux-headers-5.4.19-91)
again it dosent work .
is there any way for me to include the files not using the Cmake or if i have to how can i include them ? do they need to be make install
inside the library it self ?
EDIT: thanks to @KamilCuk for the answer which pushed me on the right track , I also found this link which has an amazing tutorial for people who just want to start System Programming .
https://sysplay.github.io/books/LinuxDrivers/book/Content/Part01.html