1 1
sgjava

How to compile libgpiod?

Recommended Posts

I've tried to compile libgpiod (my assumption is this is a user space lib) and it depends on gpio.h which is used by the kernel. According to https://github.com/brgl/libgpiod/issues/22 gpio.h should be installed with linux-libc-dev which is already installed and gpio.h is missing. I installed the kernel headers and tried (it ends up with typedef conflicts):

 

./autogen.sh --enable-tools=yes --prefix=/usr/local CFLAGS="-I/usr/src/linux-headers-4.14.14-sunxi/arch/arm/include -I/usr/src/linux-headers-4.14.14-sunxi/include"

 

configure: error: linux/gpio.h header not found (needed to build the library)

 

I've attached the config.log. Maybe I'm totally missing the boat, but there's not a lot of info out there build this for ARM and there are no deb packages for ARM I can find.

config.log

Share this post


Link to post
Share on other sites

As I understand it should be compiled against the userspace headers (/usr/src/linux-headers-$(uname -r)/inclide/uapi/linux/gpio.h).

linux-libc-dev package is irrelevant since it comes from upstream and it will contain wrong headers, and Armbian doesn't package libc-dev headers that should be installed to /usr/include/linux

Share this post


Link to post
Share on other sites

OK, I used armbian-config to get the headers since you cannot get the headers with apt-get install linux-headers-$(uname -r) or apt-get install linux-headers-generic. The later tries to pull the 4.4 headers and libgpiod requires >= 4.8. So it looks like I'm doing it right, but any combination of includes using  /usr/src/linux-headers-4.14.14-sunxi has not worked.

Share this post


Link to post
Share on other sites
On 1/24/2018 at 12:03 PM, sgjava said:

OK, I got it to build finally! I'm working on a how-to and will post that once I verify the steps and that it actually works, thanks!

 

@sgjava, could you please post how you manage to get the "linux/gpio.h" file, I am running into the same problem where the autoconfig say it could not find the 'linux/gpio.h' file, Please help with your findings. Thanks. Srin.

Share this post


Link to post
Share on other sites

@Srini gpio.h should be in the downloaded kernel headers. You can sudo find / -name gpio.h to see where it is. https://github.com/sgjava/userspaceio/blob/master/libgpiod/install.sh#L38 is where the kernel header logic is. I tested this with the latest stable release for NanoPi Duo and it worked fine. It also worked on the FriendlyElec image, but I had to manually install the headers.

Share this post


Link to post
Share on other sites
On 9/26/2018 at 10:06 PM, sgjava said:

@Srini gpio.h should be in the downloaded kernel headers. You can sudo find / -name gpio.h to see where it is. https://github.com/sgjava/userspaceio/blob/master/libgpiod/install.sh#L38 is where the kernel header logic is. I tested this with the latest stable release for NanoPi Duo and it worked fine. It also worked on the FriendlyElec image, but I had to manually install the headers.

@sgjava , Thank you so much, but even after I find the gpio.h from kernel source path and installed manually in /usr/src/linux-header-$(uname -r)/ , the configure script could not able to find the path of  "linux/gpio.h" but finally I could solve the compilation by exporting the C_INCLUDE_PATH in the shelling using "export C_INCLUDE_PATH=/usr/src/linux-headers-4.14.72-v7+/include/:/usr/include/" , it's working now.. I could build the libgpiod on the Raspberry CM3.

once again thank you so much.   

Regards,

Srini.

 

Share this post


Link to post
Share on other sites

@Srini If you look at my script I just create an include dir for artifacts missing in the compile path:

 

# Add header file missing from Linux user space includes

mkdir -p $curdir/include/linux >> $logfile 2>&1

cp /usr/src/linux-headers-$kerver/include/linux/compiler_types.h $curdir/include/linux/. >> $logfile 2>&1

log "Running autogen"

export PYTHON_VERSION=3

./autogen.sh --enable-tools=yes --enable-bindings-python --prefix=/usr/local CFLAGS="-I/usr/src/linux-headers-$kerver/include/uapi -I$curdir/include" >> $logfile 2>&1

 

I've talked to the author of libgpiod and whatever distro he's using it builds without doing any of this, but the various ARM based distros need some tweaking.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
1 1