Jump to content

How to compile libgpiod?


sgjava

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

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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.

 

Link to comment
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.

Link to comment
Share on other sites

Hi, one question about cross-compilation (e.g. for the raspberry). Do you have a working procedure? I have gone along your path but now adding stuff like arch=ARM and all these flags does not solve the issue. I can post the details but i made a lot of guessing so if you have a working procedure or you have a link that points at libgpiod cross-compilation would be very useful. 

 

Thanks 

Edited by modo
Typos
Link to comment
Share on other sites

I'm having this same trouble.  And I also don't have and can't apt install "armbian config".  I'm on a Neo Air (H2/H3).  Can someone help me get gpio.h.  I'm just trying to get control of GPIO pins on the Air that seem to be out of reach on all the libs i've been trying.  see my other post.  

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines