From "Cross-Compiling for the Omega" I cannot successfully build the gpioRead example
Here is the full response:
bjorn@bpX260:~/c-cross-compile-example$ sh xCompile.sh -buildroot ~/source/ -lib ugpioCompiling C program
/home/bjorn/source//staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/bin/mipsel-openwrt-linux-gcc -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I /home/bjorn/source//staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/usr/include -I /home/bjorn/source//staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include -I /home/bjorn/source//staging_dir/target-mipsel_24kc_musl/usr/include -I /home/bjorn/source//staging_dir/target-mipsel_24kc_musl/include gpioRead.c -o gpioRead -L/home/bjorn/source//staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/usr/lib -L/home/bjorn/source//staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/lib -L/home/bjorn/source//staging_dir/target-mipsel_24kc_musl/usr/lib -L/home/bjorn/source//staging_dir/target-mipsel_24kc_musl/lib -lugpio
/home/bjorn/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/lib/gcc/mipsel-openwrt-linux-musl/5.4.0/../../../../mipsel-openwrt-linux-musl/bin/ld: cannot find -lugpio
collect2: error: ld returned 1 exit status
makefile:9: recipe for target 'gpioRead' failed
make: *** [gpioRead] Error 1
Jackdaw last edited by
Oh yeah, you also need the library itself. I tried to cross compile it myself with my own aproach.
You need to cross compile libugpio and copy the library to
A better way to do it, is to use the package.
cd into the dir where you downloaded lede-project
$ mkdir package/libs/libugpio/
$ cd package/libs/libugpio/
$ wget https://dev.openwrt.org/export/35269/packages/libs/libugpio/Makefile
$ cd -
$ make menuconfig
save changes and exit
then build it
$ make -j4
After that, your dependencies shall be resolved.
Remember that you also need to install libugpio on the omega. You can do so by opkg install libugpio
@Flemming-Richter This is the correct answer. Actually, you need to select the libugpio in the Libraries section of "make menuconfig" so that it will actually build.
@Flemming-Richter One thing I want: onion-spi.h for SPI development. That should be included in spi-gpio-driver. However, I cannot find that in the cross build environment.
Somehow, the cross compile documentation is still pretty lacking...
@Arne-Schmitz where in menuconfig is the selection for libugpio? I searched and searched to no avail. Thank you in advance.
In order for your systems to locate the libugpio you need to use either our Source Repo or a Docker image. Here are guides on how to cross-compile C Programs and refer to our latest blog post on how to cross-compile more complex C programs with libraries. I hope this will help and make it clear to understand the purpose of Cross-Compilation, Happy Hacking
On the other hand, if you are not using our Docker Image, you will have to run
make menuconfigin the build system to select
libugpiopackage to be compiled and then compile it by running
In General you will need to have the external library, for instance
libugpio, to be compiled by the Build system before it can be dynamically linked to code that you are trying to cross compile. Above all, I strongly recommend basing your BUild system on our GitHub source repo since it is preconfigured to include the Onion software repo and to build all the libraries that are included on the Omega.
Pavel FYI I followed the instructions for 'cross-compile C Programs' and I used the source repo exactly and the instructions did not say to wget the Makefile and it was not preselected in the .config so I still got the same errors with the ugpio headers when I tried to run the example at the end of those instructions. If you read the "more complex..." section from the link in your post above that I copied below, its says it will all be done if I used that source but I still had to creat the dir, wget the files, select it in .config and then make again. I wouldn't have been able to do that unless I found this post and the example compile would never have worked. Not sure if I did something wrong or its just been missed but thanks for this post, you might want to check the repo for the lib.
"...A Small but Important Note
We keep mentioning that the program will use the ugpio library. In order for this to be possible, the library must first be compiled by LEDE build system.
If you’re using our omega2-source Docker image or building based on our source GitHub repo, you’re all good as it’s selected for compilation by default.
If not, you’ll have to run make menuconfig in the build system to select the libugpio package to be compiled and then compile it by running make.
the instructions did not say to wget the Makefile and it was not preselected in the .config
It was never mentioned that you have to
wgetthe makefile. If you followed this example, you are cloning the GitHub repo to your build system that already contains
xComile.shand the source code. The tutorial guides you through every step from building the source image and cross-compiling the program.
@Pavel-Metrokhin OK Thanks I never saw that tutorial. I think the problem is many versions of tutorials in different places, but this is good thanks.'
Douglas Kryder last edited by Douglas Kryder
yeah, that is a good point. there are no links between many of the various examples or tutorials. the original documentation did a good job in referencing and linking the documentation to additional information or another part of the documentation. are these documents able to be edited by the community?
To change the documentation, we welcome pull requests to our Onion-Docs repo on GitHub to make changes that will benefit our entire community. Docs.onion.io is generated form this repo.
Also, if you want to make any additions or changes to conent on our website (e.g. 2 Bullet Tuesday) please send us an email or let us know in the community
I cloned the Onion LEDE/OpenWrt cross-compiler yesterday (23 July 2018) from here:
It all built successfully, in an Ubuntu 16.04 VM running on my Mac.
However, like other posters on this thread, I am unable to build the cross-compile example described in the Onion documentation here:
I ran into the same "can't find ugpio/ugpio.h" error that all other posters here on this thread have described.
I see @Pavel-Metrokhin 's tutorial with "A Small but Important Note" about enabling ugpio support in the cross-compiler (via make menuconfig) here:
I've looked at the various options within "make menuconfig" and cannot find one for libugpio anywhere.
Pavel, can you please tell me where, exactly, this libugpio package option is located (within the menuconfig system?) Or - much better - please fix the pre-configured cross-compile environment. And / or fix the documentation. I find it very disconcerting that this problem has been reported to Omega on this forum for more than a year and not been fixed. The example programs should build and run flawlessly.
Same issue as most people here with the ugpio/ugpio.h error. You a major problem in continuity with your documentation and is seems like it should be an easy fix. As others have expressed, this is very irritating. Please fix
@Tim-DeBenedictis @James-Tate it's possible that you guys are overwriting the .config file with the scripts/feeds script. Please review the earlier post where the overwriting problem is described: http://community.onion.io/topic/2755/wifi-not-working-after-building-customized-image/30
I had the exact same issue. It appears the libugpio is missing in the onion/omega2-source image. The alternate link provided above (https://dev.openwrt.org/export/35269/packages/libs/libugpio/Makefile) no longer appears to be active. I did however manage to grab the Makefile from the OpenWrt_Packages repository which allowed for the example to compile finally.
In case it helps anyone, I've uploaded my pre-built omega2-source image with the libugpio library and compiled gpio example to Docker Hub here:
Yes, I am aware that this is an old topic, but I got stuck with the same issue just now I managed to get past - maybe it will help someone. Who knows...
Please use the steps described by Flemming Richter above just change the Makefile URL to https://raw.githubusercontent.com/openwrt/packages/master/libs/libugpio/Makefile
It worked for me flawlessly.
crispyoz last edited by
@Les-Nie edit /etc/opkg/distfeeds.conf, uncomment
src/gz omega2_packages http://repo.onioniot.com/omega2/packages/packages
opkg install libugpio