1

I am trying to compile a device driver to control some LEDs connected via GPIO pins. First, I got errors that /lib/modules/4.14.31-v7+/build was not found, so I ran sudo apt-get install raspberrypi-kernel-headersmade a symlink from /lib/modules/4.14.30-v7+/build/ to the folder it was searching.

I have the following includes:

#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>

Basically nothing from sys/stat.h to the end is found by compiler. I found stat.h and types.h in /usr/include/arm-linux-gnueabihf/sys/ and made a symlink to /usr/include/sys, which did not help. Instead, I tried

#include </usr/include/arm-linux-gnueabihf/sys/stat.h>
#inclue </usr/include/arm-linux-gnueabihf/sys/types.h>

which then caused the compiler to throw an error

/usr/include/arm-linux-gnueabihf/sys/stat.h:25:22: fatal error: features.h: No such file or directory
 #include <features.h>

I tried commenting out the sys/*.h files and then had the compiler throw an error for fcntl.h, and kept going and pretty much every other header was not being found.

FWIW I also tried rpi-update and rebooted. I have no idea what to do.

1
  • I think you need to install certain dev libraries... they will probably be something like sudo apt-get install lib*-dev, where I have no idea what * should be – scitronboy Apr 2 '18 at 16:52
1

The headers that were failing to include are user space only, so it was expected behaviour. @Aurora0001: you are correct that I had also some missing kernel headers I had to install.

Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.