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

Porting C code to Omega2



  • Hi to all, I'm newbie in Omega2 and crosscompiling....

    I have to port C code (born for Unix desktop) working on Ubuntu PC and on Raspberry Pi.
    Actually I can correctly compile all code using gcc.
    I bought Omega2 board (BusyBox v1.25.1 and Ω-ware: 0.2.2 b202).
    I can't change/update OS.
    Now I would like to run code (Earthworm seismic processing software) on it.

    I suppose there are two ways:

    • install gcc compiler on virtual machine, then copy binaries on Omega2 (is it possible install gcc compiler such on generic desktop linux? I think this would be simplest way....)
    • cross-compile source code

    I installed cross-compiler on Ubuntu machine, and now I started having many issues just compiling a couple of libraries....

    1. #include <rpc/types.h>
      On my Ubuntu/Raspberry gcc include path this is types.h:

    #ifndef _RPC_TYPES_H
    #define _RPC_TYPES_H 1

    typedef int bool_t;
    typedef int enum_t;
    /* This needs to be changed to uint32_t in the future */
    typedef unsigned long rpcprog_t;
    typedef unsigned long rpcvers_t;
    typedef unsigned long rpcproc_t;
    typedef unsigned long rpcprot_t;
    typedef unsigned long rpcport_t;

    #define dontcare -1

    #ifndef FALSE

    define FALSE (0)

    #endif

    #ifndef TRUE

    define TRUE (1)

    #endif

    #ifndef NULL

    define NULL 0

    #endif

    #include <stdlib.h> /* For malloc decl. /
    #define mem_alloc(bsize) malloc(bsize)
    /

    • XXX: This must not use the second argument, or code in xdr_array.c needs
    • to be modified.
      */
      #define mem_free(ptr, bsize) free(ptr)

    #ifndef makedev /* ie, we haven't already included it */
    #include <sys/types.h>
    #endif

    #if defined APPLE_CC || defined FreeBSD

    define __u_char_defined

    define __daddr_t_defined

    #endif

    #ifndef __u_char_defined
    typedef __u_char u_char;
    typedef __u_short u_short;
    typedef __u_int u_int;
    typedef __u_long u_long;
    typedef __quad_t quad_t;
    typedef __u_quad_t u_quad_t;
    typedef __fsid_t fsid_t;

    define __u_char_defined

    #endif
    #ifndef __daddr_t_defined
    typedef __daddr_t daddr_t;
    typedef __caddr_t caddr_t;

    define __daddr_t_defined

    #endif

    #include <sys/time.h>
    #include <sys/param.h>

    #include <netinet/in.h>

    #ifndef INADDR_LOOPBACK
    #define INADDR_LOOPBACK (u_long)0x7F000001
    #endif
    #ifndef MAXHOSTNAMELEN
    #define MAXHOSTNAMELEN 64
    #endif

    #endif /* rpc/types.h */

    Is it missing in cross-compiler or am I setting wrong path?

    1. #include <pthread.h>

    error: 'PTHREAD_MUTEX_ADAPTIVE_NP' undeclared

    Here the same.

    Thanks.



  • @El-Berto Just look down your inlcude path for the header files and then examine their content.

    You may find it easier to use an IDE to do your work, I use Netbeans 11 on Ubuntu 18, it will assist you by flagging errors and allowing you to open any of the files you may be referring to in your code. You could use eclipse also, but I don't fine it works as well with this compiler.



  • @crispyoz said in Porting C code to Omega2:

    @El-Berto Just look down your inlcude path for the header files and then examine their content.

    Content is different, that's why I don't know how to proceed....



  • @El-Berto this is an older mutex type, you may need to migrate the code.


Log in to reply
 

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