C++ with Digi BSP on ConnectCore 6UL SBC Express

Hello,

as long-term C++ programmer, I’d like to use C++ on ConnectCore 6UL SBC Express board using Digi’s BSP. I am using version 2.4r1 of DEY and managed to successfully build and run apix-gpio-example on the board. Now I’d like to use a C++ version of this example, for this I created a hello_world example C++ prokecta and strted adding code. But when linking, the linker complains of undefined symbols:

Invoking: DEY GCC C++ Cross-Linker
arm-dey-linux-gnueabi-g++ -march=armv7ve -marm -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/dey/2.4-r1/ccimx6ulstarter/core-image-base/sysroots/cortexa7hf-neon-dey-linux-gnueabi -o “hello_world” ./src/hello_world.o
./src/hello_world.o: In function cleanup()': /home/fk/Projects/Digi/hello_world/Debug/../src/hello_world.cpp:34: undefined reference to ldx_gpio_stop_wait_interrupt’
/home/fk/Projects/Digi/hello_world/Debug/…/src/hello_world.cpp:37: undefined reference to ldx_gpio_free' makefile:45: recipe for target 'hello_world' failed /home/fk/Projects/Digi/hello_world/Debug/../src/hello_world.cpp:38: undefined reference to ldx_gpio_free’
collect2: error: ld returned 1 exit status
make: *** [hello_world] Error 1

And here’s my sample code:

#include
#include

using namespace std;

#define TEST_LOOPS 6
#define DEFAULT_USER_LED_ALIAS “USER_LED”
#define DEFAULT_USER_BUTTON_ALIAS “USER_BUTTON”

static gpio_t *gpio_input;
static gpio_t *gpio_output;

struct gpio_interrupt_cb_data {
gpio_t *gpio;
gpio_value_t value;
int remaining_loops;
};

/*

  • cleanup() - Frees all the allocated memory before exiting
    /
    static void cleanup(void)
    {
    /
    Stop the interrupt handler thread */
    ldx_gpio_stop_wait_interrupt(gpio_input);

    /* Free gpios */
    ldx_gpio_free(gpio_input);
    ldx_gpio_free(gpio_output);
    }

int main() {
cout << “!!!Hello my World!!!” << endl; // prints !!!Hello World!!!
return 0;
}

Could you please help me to use C++ with Digi’s BSP package. According to the header libdigiapix/gpio.h, it should be ready for C++ build , because it containd extern “C” guards.

thanks

it looks like the actual library is not linked during the compilation. Look at the compilation log of C app and compare with the one for cpp

arm-dey-linux-gnueabi-g++ -march=armv7ve -marm -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/dey/2.4-r1/ccimx6ulstarter/core-image-base/sysroots/cortexa7hf-neon-dey-linux-gnueabi -o “hello_world” ./src/hello_world.o

including #include alone is not enough, you need to link with the actual library I think.
you should have something similar to:
CFLAGS += $(shell pkg-config --cflags libdigiapix)
LDLIBS += $(shell pkg-config --libs libdigiapix)

in your makefile

How/where to write these lines with Eclipse?

You need to insert the libdigiapix for the linker. For Eclipse just add “digiapix” in properties-> Cross-Linker <> Libraries