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

Omega2+ cross-compile C++ and customer headers/lib



  • I'm new to this so please bear with me! (sorry I dont know how to insert code, help?)

    I want to use the Omega2+ to compile C++ code and will be wanting to use (fast) GPIO read and write on the chip, i2c devices to control GPIO expanders (e.g.: MCP23017-E/SP) and an OLED. However I'm stuck at the 'Start' square.

    I've followed the instruction set in the docs.onion.../cross-compiling and was able to get the (C) gpio example working - but will note, it was not mentioned you need to manually find, download and copy the header files into the appropriate directory.

    Then, I tried the simplest possible 'hello world' C++ program. Ultimately, i was able to compile with the makefile below. Note: adding gpp vs. gcc, removing -l$(LIB) since I have no libraries. Copied the compiled file over to the Omega, chmod, ./helloworld,... and got something similar to:

    /asd: line 1: syntax error: unexpected "(" (expecting ")")

    So,.. is the Omega trying to interpret my compiled c++ code? why did this not work? Do I need to change some settings to have a different compiler run it (gpp vs gcc)? I've been bashing my head on this for so long I'm starting to get worried I'm over looking the obvious. Any help would be MUCH appreciated!!! Besides, I think having something well documented for how to run c++ would be very beneficial to the community

    Assumption:

    1. I will need to compile C++ code with customer headers for peripherals (e.g. sparkfun...)
    2. I am running Linux Mint
    3. Using Omega2+ v0.1.10
    4. I've gone through cross-compile set up tutorial and can successfully run the example gpio C program.

    . # main compiler
    CXX := gpp #gpp for C++ or gcc for 'C'
    CC := gcc #gpp for C++ or gcc for 'C'

    .# Input (and) Output File name ("exe")
    TARGET1 := Omega2_Test_GPIO

    .# What does this do?
    all: $(TARGET1)

    $(TARGET1):
    @echo "Compiling C program"
    $(CXX) $(CFLAGS) $(TARGET1).cpp -o $(TARGET1) $(LDFLAGS)
    #$(CC) $(CFLAGS) $(TARGET1).cpp -o $(TARGET1) $(LDFLAGS) #-l$(LIB)

    clean:
    @rm -rf $(TARGET1) $(TARGET2)


  • administrators

    @OSO-Bear Judging by the output of the program and your makefile, it looks like your program was compiled for x86 (your computer). You'll have to use an xCompile.sh script like the example to cross compile your C program.

    PS it's three backticks to open a code block, and three to close it. See this link for more markdown syntax.



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