Cross Compiling on the Omega2



  • Thank you, I tried with sudo and then the command:

    this is what i get:

    sudo: /root/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/bin/mipsel-openwrt-linux-gcc: command not found

    Is there an error with the installation of the toolchain?



  • @MarshalllGG Sorry I don't use the docker image I prefer to install on my own Ubuntu 20 system, however I suspect the correct compiler path is:

    staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-gcc

    Note that the gcc version is 7.3.0 instead of 5.4.0



  • Okay I compiled successfully hello wolrd, now the problem is when I link external libraries..
    I linked with this syntax:

    root@229a08e06724:~/source/projects/c-cross-compile-example# sh xCompile.sh -buildroot /root/source -lib "oled-exp -ludpsocketlib"

    the library I want to use is my own "udpsocketlib.c" and the header file is "udpsocketlib.h" (all in the same directory with makefile and the main of my udpserver.c program

    The error I got this time is this:

    make: /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-gcc: Command not found
    makefile:9: recipe for target 'udpserver' failed
    make: *** [udpserver] Error 127



  • @MarshalllGG

    Sorry, I don't use docker either..

    To get to know compiling process in detail, would suggest the following book to anyone:
    Advanced C and C++ Compiling by Milan Stevanovic

    Thanks.



  • @MarshalllGG Maybe you will find this easier if you use Apache Netbeans IDE, take a look at my article on setting up to use with the cross compiler:

    https://community.onion.io/topic/4131/setup-netbeans-11-for-c-c-development-cross-compilation/2?_=1628474815438



  • @crispyoz
    Thank you,
    I'm trying to setup netbeans, but when I open 'tools' in the c/c++ I have a different screen:
    I Need to setup a ccls configuration (?)

    I tried Also a lot to crosscompile my c programs with the Onion's tutorial, but I noticed that also the c-cross-compile-example with gpioRead fails in compilation:

    makefile:9: recipe for target 'gpioRead' failed
    make *** [gpioRead] Error 127

    Do you know if cross compilation is the only method to use the OLED expansion C libraries?



  • @MarshalllGG I can't guess what your netbeans screen looks like so you need to post it.

    So we can see what the issue is with your cross-compiling post more of the output.

    My crystal ball is in the shop šŸ™‚



  • @crispyoz

    I'm sorry, here's my screen

    alt text



  • @MarshalllGG Looks like there is some problem with your plugin . Look in Tools Plugins and check you have the correct plugin installed per the attached screen.
    plugin.png



  • Ye I found also this.

    Schermata del 2021-08-14 17-59-16.png

    In my netbeans I see this and then I search tools and I get the last screen I posted.



  • @MarshalllGG You need to activate "User Installed Plugins" it is currently inactive.



  • Okay @crispyoz thank you very much, I installed successfully Netbeans and seems to be working in the right way.
    I need some other tips also because it's the first time I use a tool like this (to compile simple programs I had only textedit and the terminal).

    Now I created my C project and in my source folder I have the main, for example a program to display "hello world" on the OLED screen of the omega.

    How can I link the oled C libraries in the cross-compilation with NetBeans? Do I have to download them or are stored in the usr/lib folder ?

    Thank you another time šŸ˜Š



  • @MarshalllGG Right click on your project, choose properties, then select Linker on the left and you can configure the path to your libraries in "Additional Library Directories" is you have the build system installed then this would be the path, source/staging_dir/target-mipsel_24kc_musl/usr/lib

    Then in the same screen "Libraries", then "Add Library File" and browse the file system to select source/staging_dir/target-mipsel_24kc_musl/usr/lib/libonionoledexp.so



  • @crispyoz

    Thank you I'm trying now but seems that the libonionoledexp isn't installed, this is the screen:
    Schermata del 2021-08-17 09-48-06.png



  • @MarshalllGG Take a look in make menuconfig and ensure you have selected Onion->Libraries->libonionoledexp, if it is not selected, select it then run make



  • Same problem
    Maybe do I need to compile another time the toolchain?

    Schermata del 2021-08-17 10-04-24.png
    Schermata del 2021-08-17 10-05-21.png

    also searching "oled" no matches found



  • @MarshalllGG From the main menu "Onion" then "Libraries"



  • @crispyoz
    Okay I did all these things and I tried to build the project:

    Schermata del 2021-08-17 16-07-49.png

    The libraries I included are:

    -libonionoledexp.so
    -libonioni2c.so
    -liboniondebug.so



  • @MarshalllGG In Project Properties, select "C Compiler" in the left side menu, then add to "include directories" source/staging_dir/target-mipsel_24kc_musl/usr/inlcude



  • Hey @crispyoz I'm sorry I didn't thanked you, now I'm using the Omega2+ for some projects with threads and semaphores and I wanted ask you how to add the flag -lpthread in linking (because I think it's for this that the run command gives me error in make)



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