sgjava Posted January 23, 2018 Posted January 23, 2018 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
zador.blood.stained Posted January 23, 2018 Posted January 23, 2018 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
sgjava Posted January 23, 2018 Author Posted January 23, 2018 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.
sgjava Posted January 24, 2018 Author Posted January 24, 2018 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! 2
Srini Posted September 26, 2018 Posted September 26, 2018 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.
sgjava Posted September 26, 2018 Author Posted September 26, 2018 @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.
Srini Posted September 28, 2018 Posted September 28, 2018 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.
sgjava Posted September 28, 2018 Author Posted September 28, 2018 @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.
modo Posted April 9, 2019 Posted April 9, 2019 (edited) 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 April 9, 2019 by modo Typos
dareis Posted September 18, 2019 Posted September 18, 2019 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.
abdul Posted May 31, 2020 Posted May 31, 2020 Hi Can we compile libgpiod on window? if yes then how? what would be the --prefix=? value
Recommended Posts