We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

From "Cross-Compiling for the Omega" I cannot successfully build the gpioRead example



  • @Jackdaw said in From "Cross-Compiling for the Omega" I cannot successfully build the gpioRead example:

    @Stephen-Wright said in From "Cross-Compiling for the Omega" I cannot successfully build the gpioRead example:

    ugpio

    I think you need libugpio headers https://github.com/mhei/libugpio. Copy those to staging_dir/target-mipsel_24kc_musl/usr/include/ and then compile.

    What do you mean "copy"? fork the whole https://github.com/mhei/libugpio into "staging_dir/target-mipsel_24kc_musl/usr/include/" ?



  • No like I said, you need the header. Copy ugpio.h to staging_dir/target-mipsel_24kc_musl/usr/include/



  • I tried to copy all files in https://github.com/mhei/libugpio/tree/master/src to staging_dir/target-mipsel_24kc_musl/usr/include/ugpio but got "fatal error: ugpio-version.h: No such file or directory"
    There is a file ugpio-version.h.in but no ugpio-version.h



  • @Bjorn-Pehrson Rename it to ugpio-version.h



  • @Jackdaw
    I just tried that and xame a bit further but no completion. I now got
    cannot find -lugpio
    collect2: error: ld returned 1 exit status
    makefile:9: recipe for target 'gpioRead' failed
    make: *** [gpioRead] Error 1



  • 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



  • 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 staging_dir/target-mipsel_24kc_musl/usr/lib/



  • 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 menuconfig in the build system to select libugpio package to be compiled and then compile it by running make.

    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-Metrokhin

    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.
    ..."



  • @Andrew-Moore said in From "Cross-Compiling for the Omega" I cannot successfully build the gpioRead example:

    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 wget the makefile. If you followed this example, you are cloning the GitHub repo to your build system that already contains makefile, xComile.sh and 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.'



  • 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:

    https://github.com/OnionIoT/source.git

    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:

    https://docs.onion.io/omega2-docs/cross-compiling.html

    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:

    https://onion.io/2bt-cross-compiling-c-programs-part-3/

    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.

    Thanks.

    Tim



  • 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



Looks like your connection to Community was lost, please wait while we try to reconnect.