Home/Support/Support Forum/C++ with Digi BSP on ConnectCore 6UL SBC Express
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

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

0 votes

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 <iostream>
#include <libdigiapix/gpio.h>

using namespace std;

#define TEST_LOOPS 6

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 */

/* Free gpios */

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.

asked Oct 5, 2018 in Linux by fkaduch New to the Community (0 points)
edited Oct 9, 2018 by LeonidM

Please log in or register to answer this question.

2 Answers

0 votes
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 <libdigiapix/gpio.h> 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
answered Oct 9, 2018 by LeonidM Veteran of the Digi Community (2,541 points)
How/where to write these lines with Eclipse?
0 votes
You need to insert the libdigiapix for the linker. For Eclipse just add "digiapix" in properties-> Cross-Linker <> Libraries
answered Nov 14, 2018 by jean-marc jobin New to the Community (3 points)