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

Using Protobuf - Error



  • Hello,
    I am trying to cross compile a program for the Omega2+.

    The downloading of the toolchain and compiling of toolchain worked so far.
    I can compile the gpioRead.c example application (https://github.com/OnionIoT/c-cross-compile-example).

    I enabled the protobuf library and also the protobuf-c library in the make menuconfig.

    This is the modified gpioRead.cpp, just to note here the import of the protobuf file.

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <fcntl.h>
    
    #include <ugpio/ugpio.h>
    
    
    #include<zmq.h>
    
    #include "attentive_framework.pb.h"
    
    using namespace attentivemachines;
    
    int main(int argc, char **argv, char **envp)
    {
            PBImageSample* image = new PBImageSample();
    
    
    
    

    I use this command (I modified the makefile a litte bit to also compile my attentive_framework.pb.cc and also changed to c++):

    sh xCompile.sh -buildroot /root/source -lib libsodium -lib protobuf -lib z -lib ugpio

    Scroll down for error at the bottom:

    Compiling C program
    /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-gcc -v -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 /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include -I /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include -I /root/source/staging_dir/target-mipsel_24kc_musl/usr/include -I /root/source/staging_dir/target-mipsel_24kc_musl/include gpioRead.cpp attentive_framework.pb.cc  -o gpioRead -L/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/lib -L/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib -L/root/source/staging_dir/target-mipsel_24kc_musl/usr/lib -L/root/source/staging_dir/target-mipsel_24kc_musl/lib -lugpio
    Reading specs from /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/specs
    COLLECT_GCC=/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-gcc
    COLLECT_LTO_WRAPPER=/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/libexec/gcc/mipsel-openwrt-linux-musl/7.3.0/lto-wrapper
    Target: mipsel-openwrt-linux-musl
    Configured with: /root/source/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/gcc-7.3.0/configure --with-bugurl=http://www.lede-project.org/bugs/ --with-pkgversion='OpenWrt GCC 7.3.0 r7477-573c4abcc8' --prefix=/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=mipsel-openwrt-linux-musl --with-gnu-ld --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-multilib --disable-libmpx --disable-nls --without-isl --without-cloog --with-host-libstdcxx=-lstdc++ --with-float=soft --with-gmp=/root/source/staging_dir/host --with-mpfr=/root/source/staging_dir/host --with-mpc=/root/source/staging_dir/host --disable-decimal-float --with-mips-plt --with-diagnostics-color=auto-if-env --disable-libssp --enable-__cxa_atexit --with-headers=/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include --disable-libsanitizer --enable-languages=c,c++ --enable-shared --enable-threads --with-slibdir=/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib --enable-lto --with-libelf=/root/source/staging_dir/host
    Thread model: posix
    gcc version 7.3.0 (OpenWrt GCC 7.3.0 r7477-573c4abcc8) 
    COLLECT_GCC_OPTIONS='-v' '-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=1' '-Werror=format-security' '-fstack-protector' '-D' '_FORTIFY_SOURCE=1' '-I' '/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include' '-I' '/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include' '-I' '/root/source/staging_dir/target-mipsel_24kc_musl/usr/include' '-I' '/root/source/staging_dir/target-mipsel_24kc_musl/include' '-o' 'gpioRead' '-L/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/lib' '-L/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib' '-L/root/source/staging_dir/target-mipsel_24kc_musl/usr/lib' '-L/root/source/staging_dir/target-mipsel_24kc_musl/lib' '-mllsc' '-mplt' '-mno-shared' '-EL' '-mabi=32'
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/libexec/gcc/mipsel-openwrt-linux-musl/7.3.0/cc1plus -quiet -v -I /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include -I /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include -I /root/source/staging_dir/target-mipsel_24kc_musl/usr/include -I /root/source/staging_dir/target-mipsel_24kc_musl/include -D_GNU_SOURCE -idirafter BUILDROOT_PATH/staging_dir/usr/include -D _FORTIFY_SOURCE=1 gpioRead.cpp -mel -quiet -dumpbase gpioRead.cpp -mno-branch-likely -mips32r2 -mtune=24kc -msoft-float -mips16 -minterlink-mips16 -mllsc -mplt -mno-shared -mabi=32 -auxbase gpioRead -Os -Wno-error=unused-but-set-variable -Wno-error=unused-result -Wformat=1 -Werror=format-security -version -fno-caller-saves -fno-plt -fhonour-copts -fstack-protector -o - |
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/bin/as -v -I /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include -I /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include -I /root/source/staging_dir/target-mipsel_24kc_musl/usr/include -I /root/source/staging_dir/target-mipsel_24kc_musl/include -EL -mips32r2 -mips16 -O2 -no-mdebug -mabi=32 -mno-shared -mtune=24kc -msoft-float -call_nonpic -o /tmp/ccqoGQlK.o
    GNU assembler version 2.29.1 (mipsel-openwrt-linux-musl) using BFD version (GNU Binutils) 2.29.1
    GNU C++14 (OpenWrt GCC 7.3.0 r7477-573c4abcc8) version 7.3.0 (mipsel-openwrt-linux-musl)
    	compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    ignoring nonexistent directory "BUILDROOT_PATH/staging_dir/usr/include"
    ignoring duplicate directory "/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include"
      as it is a non-system directory that duplicates a system directory
    #include "..." search starts here:
    #include <...> search starts here:
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include
     /root/source/staging_dir/target-mipsel_24kc_musl/usr/include
     /root/source/staging_dir/target-mipsel_24kc_musl/include
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/include/c++/7.3.0
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/include/c++/7.3.0/mipsel-openwrt-linux-musl
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/include/c++/7.3.0/backward
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/sys-include
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/include
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/include
    End of search list.
    GNU C++14 (OpenWrt GCC 7.3.0 r7477-573c4abcc8) version 7.3.0 (mipsel-openwrt-linux-musl)
    	compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    Compiler executable checksum: 87c2492f90fb558f9f6538855eedc049
    COLLECT_GCC_OPTIONS='-v' '-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=1' '-Werror=format-security' '-fstack-protector' '-D' '_FORTIFY_SOURCE=1' '-I' '/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include' '-I' '/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include' '-I' '/root/source/staging_dir/target-mipsel_24kc_musl/usr/include' '-I' '/root/source/staging_dir/target-mipsel_24kc_musl/include' '-o' 'gpioRead' '-L/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/lib' '-L/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib' '-L/root/source/staging_dir/target-mipsel_24kc_musl/usr/lib' '-L/root/source/staging_dir/target-mipsel_24kc_musl/lib' '-mllsc' '-mplt' '-mno-shared' '-EL' '-mabi=32'
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/libexec/gcc/mipsel-openwrt-linux-musl/7.3.0/cc1plus -quiet -v -I /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include -I /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include -I /root/source/staging_dir/target-mipsel_24kc_musl/usr/include -I /root/source/staging_dir/target-mipsel_24kc_musl/include -D_GNU_SOURCE -idirafter BUILDROOT_PATH/staging_dir/usr/include -D _FORTIFY_SOURCE=1 attentive_framework.pb.cc -mel -quiet -dumpbase attentive_framework.pb.cc -mno-branch-likely -mips32r2 -mtune=24kc -msoft-float -mips16 -minterlink-mips16 -mllsc -mplt -mno-shared -mabi=32 -auxbase attentive_framework.pb -Os -Wno-error=unused-but-set-variable -Wno-error=unused-result -Wformat=1 -Werror=format-security -version -fno-caller-saves -fno-plt -fhonour-copts -fstack-protector -o - |
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/bin/as -v -I /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include -I /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include -I /root/source/staging_dir/target-mipsel_24kc_musl/usr/include -I /root/source/staging_dir/target-mipsel_24kc_musl/include -EL -mips32r2 -mips16 -O2 -no-mdebug -mabi=32 -mno-shared -mtune=24kc -msoft-float -call_nonpic -o /tmp/ccrPppBJ.o
    GNU assembler version 2.29.1 (mipsel-openwrt-linux-musl) using BFD version (GNU Binutils) 2.29.1
    GNU C++14 (OpenWrt GCC 7.3.0 r7477-573c4abcc8) version 7.3.0 (mipsel-openwrt-linux-musl)
    	compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    ignoring nonexistent directory "BUILDROOT_PATH/staging_dir/usr/include"
    ignoring duplicate directory "/root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include"
      as it is a non-system directory that duplicates a system directory
    #include "..." search starts here:
    #include <...> search starts here:
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include
     /root/source/staging_dir/target-mipsel_24kc_musl/usr/include
     /root/source/staging_dir/target-mipsel_24kc_musl/include
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/include/c++/7.3.0
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/include/c++/7.3.0/mipsel-openwrt-linux-musl
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/include/c++/7.3.0/backward
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/sys-include
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/../../../../mipsel-openwrt-linux-musl/include
     /root/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib/gcc/mipsel-openwrt-linux-musl/7.3.0/include
    End of search list.
    GNU C++14 (OpenWrt GCC 7.3.0 r7477-573c4abcc8) version 7.3.0 (mipsel-openwrt-linux-musl)
    	compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    Compiler executable checksum: 87c2492f90fb558f9f6538855eedc049
    {standard input}: Assembler messages:
    {standard input}:26625: Error: opcode not supported on this processor: mips32r2 (mips32r2) `sync'
    makefile:10: recipe for target 'gpioRead' failed
    make: *** [gpioRead] Error 1
    
    

    Error: opcode not supported on this processor: mips32r2 (mips32r2) `sync'

    So there is this error, what I think now is that the error is in the precompiled protobuf library, am I correct?

    I did the protoc compilation on the Ubuntu Linux machine, so the generated attentive_framework.pb.h and .cc are generated by this, but this should not be that problem right?

    Thanks



  • @joh I suspect you are correct. The error indicates that either you have some assembler code in your code base that is making use of an opcode not supported on this processor, or you are using a library that does the same or has been compiled such that it does the same. I don't use attentive_framework (not sure what it is!) but you can check binary files to see what platform they were compiled for, using the "file" command. For example:

    file ~/source//staging_dir/target-mipsel_24kc_musl/usr/lib/libfdisk.so

    Reports:

    ~/source//staging_dir/target-mipsel_24kc_musl/usr/lib/libfdisk.so: symbolic link to libfdisk.so.1

    So now run:

    file ~/source//staging_dir/target-mipsel_24kc_musl/usr/lib/libfdisk.so.1

    Reports:
    ~/source//staging_dir/target-mipsel_24kc_musl/usr/lib/libfdisk.so.1: symbolic link to libfdisk.so.1.1.0

    So now run:

    file ~/source//staging_dir/target-mipsel_24kc_musl/usr/lib/libfdisk.so.1.1.0

    Reports:

    ~/source//staging_dir/target-mipsel_24kc_musl/usr/lib/libfdisk.so.1.1.0: ELF 32-bit LSB shared object, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, with debug_info, not stripped

    So now we know what processor the library was built for.



  • Ok thanks the file command is a helpful tip. In the target dir there is the correct file.

    I managed to compile it with the compiler option -march=mips32r2, I don't know why this is not working in the xCompile.sh script..



  • @joh my guess is that it is not picking up the correct library, add -d option to your command line so script will spit out the details.



  • I just tried compiling "protobuf" in an Omega2+, after installing gcc (with an sd card overlay).

    protobuf-3.13.0 (latest):
    root@Omega-745F:~# wget -c https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protobuf-cpp-3.13.0.tar.gz
    root@Omega-745F:~# tar xf protobuf-cpp-3.13.0.tar.gz
    root@Omega-745F:~# cd protobuf-3.13.0
    root@Omega-745F:~/protobuf-3.13.0#./confiure
    ..
    ..
    checking zlib version... headers missing or too old (requires 1.2.0.4)
    checking whether g++ supports C++11 features by default... yes
    checking whether -latomic is needed... yes
    checking whether gcc is Clang... no
    checking whether pthreads work with -pthread... no
    checking whether pthreads work with -pthreads... no
    checking for the pthreads library -lpthreads... no
    checking whether pthreads work without any flags... no
    checking whether pthreads work with -Kthread... no
    checking whether pthreads work with -pthread... no
    checking whether pthreads work with -pthreads... no
    checking whether pthreads work with -mthreads... no
    checking for the pthreads library -lpthread... no
    checking whether pthreads work with --thread-safe... no
    checking whether pthreads work with -mt... no
    checking for pthread-config... no
    checking the location of hash_map... <unordered_map>
    ..
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating scripts/gmock-config
    config.status: creating build-aux/config.h
    config.status: executing depfiles commands
    config.status: executing libtool commands
    root@Omega-745F:~/protobuf-3.13.0# make
    ..
    make[2]: Entering directory '/root/protobuf-3.13.0/src'
    CXX google/protobuf/compiler/main.o
    CXX google/protobuf/stubs/bytestream.lo
    CXX google/protobuf/stubs/common.lo
    google/protobuf/stubs/common.cc:50:2: error: #error "No suitable threading library available."
    #error "No suitable threading library available."

    protobuf-2.6.1:
    root@Omega-745F:~# wget -c https://github.com/protocolbuffers/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.bz2
    root@Omega-745F:~# tar xf protobuf-2.6.1.tar.bz2
    root@Omega-745F:~# cd protobuf-2.6.1
    root@Omega-745F:~/protobuf-2.6.1# ./configure
    ..
    checking zlib version... ok (1.2.0.4 or later)
    checking for library containing zlibVersion... no
    checking for the pthreads library -lpthreads... no
    checking whether pthreads work without any flags... yes
    checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
    checking if more special flags are required for pthreads... no
    checking whether to check for GCC pthread/shared inconsistencies... yes
    checking whether -pthread is sufficient with -shared... yes
    checking whether what we have so far is sufficient with -nostdlib... yes
    ..
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating scripts/gtest-config
    config.status: creating build-aux/config.h
    config.status: executing depfiles commands
    config.status: executing libtool commands
    root@Omega-745F:~/protobuf-2.6.1# make
    ..
    libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -O2 -g -DNDEBUG -MT google/proo
    /tmp/ccoONjbE.s: Assembler messages:
    /tmp/ccoONjbE.s:1926: Error: opcode not supported on this processor: mips1 (mips1) sync' /tmp/ccoONjbE.s:4614: Error: opcode not supported on this processor: mips1 (mips1) sync'
    /tmp/ccoONjbE.s:5532: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    make[2]: *** [Makefile:2055: google/protobuf/stubs/common.lo] Error 1
    make[2]: Leaving directory '/root/protobuf-2.6.1/src'
    make[1]: *** [Makefile:700: all-recursive] Error 1
    make[1]: Leaving directory '/root/protobuf-2.6.1'
    make: *** [Makefile:606: all] Error 2

    protobuf-2.4.1: (the very first version available for download)
    root@Omega-745F:~# wget -c https://github.com/protocolbuffers/protobuf/releases/download/v2.4.1/protobuf-2.4.1.tar.bz2
    root@Omega-745F:~# tar xf protobuf-2.4.1.tar.bz2
    root@Omega-745F:~# cd protobuf-2.4.1/
    root@Omega-745F:~/protobuf-2.4.1# ./configure
    ..
    checking zlib version... ok (1.2.0.4 or later)
    checking for library containing zlibVersion... no
    checking for the pthreads library -lpthreads... no
    checking whether pthreads work without any flags... yes
    checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
    checking if more special flags are required for pthreads... no
    checking whether to check for GCC pthread/shared inconsistencies... yes
    checking whether -pthread is sufficient with -shared... yes
    checking whether what we have so far is sufficient with -nostdlib... yes
    ..
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating scripts/gtest-config
    config.status: creating build-aux/config.h
    config.status: executing depfiles commands
    config.status: executing libtool commands
    root@Omega-745F:~/protobuf-2.4.1# time make
    ..
    make[3]: Leaving directory '/root/protobuf-2.4.1/src'
    make[2]: Leaving directory '/root/protobuf-2.4.1/src'
    make[1]: Leaving directory '/root/protobuf-2.4.1'
    real 1h 16m 46s
    user 1h 6m 01s
    sys 2m 10.58s
    root@Omega-745F:~/protobuf-2.4.1#

    Note:
    Omega2+ (128MB) requires 50MB+ swap for compilation

    root@Omega-745F:~/protobuf-3.13.0# free
    total used free shared buffers cached
    Mem: 124808 101348 23460 8 14884 31080
    -/+ buffers/cache: 55384 69424
    Swap: 131068 2048 129020

    Without swap compilation fails for v.2.4.1, which is the only version that still stays in after a few seconds since "make" is run):

    virtual memory exhausted: Out of memory
    make[2]: *** [Makefile:1179: descriptor.lo] Error 1
    make[2]: Leaving directory '/root/protobuf-2.4.1/src'
    make[1]: *** [Makefile:530: all-recursive] Error 1
    make[1]: Leaving directory '/root/protobuf-2.4.1'
    make: *** [Makefile:435: all] Error 2

    Note:
    There are a few warnings while compiling v 2.4.1, all of them says :
    ..
    "locally defined but not used [-Wunused-lo]"

    Here is the pthread and gcc info:
    root@Omega-745F:~# opkg files libpthread
    Package libpthread (1.1.19-1) is installed on root and has the following files: (does not list any files)
    root@Omega-745F:~#

    root@Omega-745F:~# opkg files gcc
    Package gcc (5.4.0-3) is installed on root and has the following files:
    /usr/include/linux/mmtimer.h
    ..

    Thanks.



  • @tjoseph1 To me it just makes no sense to compile anything on the device, it's just a dead end waiting to occur. The better long term solution is to resolve the issue with the cross compilation of the code. But we need a little more info to be able to troubleshoot it. It looks like xCompile has been modified so we need to see what it is actually doing and where it is looking.



  • @crispyoz :
    protobuf v2.4.1 compiles.. v2.6.1 & v3.13.0 do not compile at all.. Both terminates giving out pthread related error.. may be the newer code was written for later versions of libs.

    The "native" gcc version in the device appears to be 5.4.0.

    I read somewhere that the run-time and the compiler have to match. The executable code generated by newer compiler can not expected to be fully supported by older run-time; where as newer run-time shall fully support executable from older compilers..if I remember it correctly.

    If that is the case, shouldn't that be a concern ?

    If we compile the app with cross-compiler(toolchain-mipsel_24kc_gcc-7.3.0_musl) and take it to the device that has an older run-time, will that work flawlessly?

    When I use the cross compiler, and check with the file command:
    $ file <executable> the output shows:
    ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-mipsel-sf.so.1, not stripped

    /lib/ld-musl-mipsel-sf.so.1 is present in the device as a link to /lib/libc.so

    The executables generated in the device (using 5.4.0) are also pointing to the same libc.
    I guess that is the "correct" run-time for "toolchain-mipsel_24kc_gcc-7.3.0_musl" ?

    readelf shows that the header data are different for the exes generated by "native" and "cross" compilers.

    Thanks..



  • @tjoseph1 If you compile on a later version of the compiler, that compiler can be expected to include updated versions of the various libraries you'll need. When you then move your app to a system with an older version set of libraries then some of the code you are calling may not even exist in those older libraries and certainly their entry points could be expected to change. Any of your dependencies will ultimately have a dependency on the GLIBC, so if you are compiling against a newer version of GLIBC then attempting to run against an older version of GLIBC you may run into trouble. Possibly you can update GLIBC but there may be kernel version dependencies. A bit of a slippery slope.

    Cross compilation does complicate things, but if you're building anything of any complexity and you try to do it on the Omega2(+) you'll eventually run out of resources and you'll certainly end up getting frustrated with the performance. This is not an Omega thing, IoT devices are designed to be minimalist.

    IMHO learning to work with the cross compilation model is the best solution.



  • @crispyoz :

    xCompling is the preferred for me. I did the above experiment with "protobuf" to see how it goes with native build tools. At least we know that Omega2's native env does not support protobuf.

    The /lib/libc.so is from package libc (1.1.19-1).

    root@Omega-745F:~/protobuf-2.4.1# opkg files libc
    Package libc (1.1.19-1) is installed on root and has the following files:
    /lib/ld-musl-mipsel-sf.so.1
    /lib/libc.so

    Is libc-1.1.19-1 fully support with the gcc-7.3.0_musl ?
    Otherwise simple things may work, others may not, I guess.

    Omega2+ is limited .. as per 21C standards. It is much much better than a 200MHz PentiumPro with its 66MHz FSB "loaded with" 64 MB EDO (less an FPU) šŸ™‚

    Sometimes it is very inspirational reading about the great men at Bell labs and their PDP-11 where both C and Unix were born.

    Coming back to the "compatibility" .. Don't I have to compile the entire stuff as static then (in the cross compiler) and move to Omega2?

    And isn't that applicable to the OP @joh wrt his efforts with protobuf if that stuff ever going to work properly in an Omega2 ?

    Thanks..



  • @tjoseph1 take a look at musl.libc.org for compatibility details, they typically document the binutils and gcc minimum requirements therein .

    The problem with static compilation is that if you are developing commercial stuff you will likely run afoul of GPL.



  • @crispyoz :
    Thanks a lot for pointing to the license issue..
    You helped me clarifying all the doubts I had wrt onion in this forum.
    In this specific scenario, protobuf is BSD & musl is MIT. I couldn't find a GPL related binding for any (including commercial) usage that require only those two.
    I would think that you were giving me an advise to Read The Fine License of all the libs that I may use in my endeavor..
    Please let me know..if I missed it, it is important me to know that I am not in violation.



  • @tjoseph1 I was making the more general point that if you are considering static linking of anything you need to understand the licensing implication, as you do whenever you are using any third party library. I don't have any concerns about Omega and OpenWrt OOB, but developers often require other third party libraries and it really sucks when you spend weeks or months developing something then suddenly realise you've used GPL'd libraries and need to release the source to your commercial product.

    I'm all in favour of open source licensing and I don't have any issue personally with any of the licenses, but when we are developing products we need to be cognizant of the impacts of the choices we are making. Law suits really hurt your profit margin šŸ™‚



  • @crispyoz :
    Thanks.. I share your thoughts; RTF License.

    GPL might have been the right thing for RMS to counter the 'boxed s/w' (with a price tag) that appeared in the 80s. If I remember it correctly, the owner of Brunei was the wealthiest & MJackson was the top most earning, those days.

    Things changed..boxed phenomenon extended to boxed implementors..to the extent..that..
    power does not last..card does not read..help..!!

    I respect RMS & the developers who think GPL is the right model to release their s/w. There must be a reason for glibc docs carry his name on page#1.

    I read somewhere that, IBM did have a policy, to evaluate if a prosepectve customer was worthy to buy/operate the "room full" computer, before IBM accepted the purchase order.

    I guess, Bugatti, RR and many others do that even today..



  • @tjoseph1 RMS earned his spot.

    Blackberry used to require certain capabilities before they would agree to deploy their BES system in an enterprise.

    I bought a Bentley, they didn't care about anything other than I could pay the bill.

    I was going to call Bugatti and see if I could order a Veyron but you can't drive them on the road in Sydney as they are left hand drive. And there was a small problem of the $2.8m price tag šŸ˜ž



  • @crispyoz :
    As a proud owner of a Bentley, you may not want to go for Bugatti.
    "If I go this route, what is it going to bring in, that I do not already have?" Mask of Zorro..

    Get a Cessna..:)



  • @crispyoz :

    https://codescape.mips.com/sdk/v2.0.0k/docs/_static/gpl_3.1.txt
    is detailing about "GCC RUNTIME LIBRARY EXCEPTION" which I understand if correctly, permits using compiler and run-time, while not requiring the source of the work to be made available as in the case of a pure GPL approach ?

    As you have correctly pointed-out, using other GPLed libraries from other sources will require that GPL be strictly followed, unless specified otherwise in those libs.

    Thanks ..



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