Link error occur when importing EI SDK to infineon EVB project

Hello, I deploy a C++ library outside the EI, then import to my infineon modustoolbox project,and I get some problems when compile and link as following, is there any setting need to be config?
The compile is passed, but link fail。

I have added the macro definition at the beginning of main.cpp file:
#define EIDSP_USE_CMSIS_DSP 1
#define EIDSP_LOAD_CMSIS_DSP_SOURCES 1

Linking output file mtb-example-psoc6-hello-world.elf
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/edge-impulse-sdk/dsp/dct/fast-dct-fft.o: in function ei::ei_matrix::ei_matrix(unsigned long, unsigned long, float*)': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/edge-impulse-sdk/dsp/dct/../numpy_types.h:104: undefined reference to ei_calloc(unsigned int, unsigned int)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/edge-impulse-sdk/dsp/dct/fast-dct-fft.o: in function ei::numpy::software_rfft(float*, ei::fft_complex_t*, unsigned int, unsigned int)': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/edge-impulse-sdk/dsp/dct/../numpy.hpp:2231: undefined reference to ei_free(void*)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/edge-impulse-sdk/dsp/dct/fast-dct-fft.o: in function ei::ei_matrix::ei_matrix(unsigned long, unsigned long, float*)': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/classifier/ei_run_classifier.h:574: undefined reference to ei_printf(char const*, …)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/main.o: in function ei::speechpy::feature::filterbanks(ei::ei_quantized_matrix*, unsigned short, int, unsigned long, unsigned long, unsigned long, bool)': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/speechpy/feature.hpp:68: undefined reference to ei_malloc(unsigned int)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/speechpy/feature.hpp:95: undefined reference to ei_malloc(unsigned int)' c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/speechpy/feature.hpp:97: undefined reference to ei_free(void*)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/speechpy/feature.hpp:117: undefined reference to ei_free(void*)' c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/speechpy/feature.hpp:122: undefined reference to ei_malloc(unsigned int)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/speechpy/feature.hpp:124: undefined reference to ei_free(void*)' c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/speechpy/feature.hpp:130: undefined reference to ei_free(void*)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/main.o: in function ei::ei_matrix::~ei_matrix()': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/spectral/../numpy_types.h:129: undefined reference to ei_free(void*)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/main.o: in function ei::ei_matrix::ei_matrix(unsigned long, unsigned long, float*)': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/spectral/../numpy_types.h:104: undefined reference to ei_calloc(unsigned int, unsigned int)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/main.o: in function ei::ei_matrix::~ei_matrix()': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/spectral/../numpy_types.h:129: undefined reference to ei_free(void*)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/main.o: in function ei::ei_matrix::ei_matrix(unsigned long, unsigned long, float*)': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/spectral/../numpy_types.h:104: undefined reference to ei_calloc(unsigned int, unsigned int)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/main.o: in function ei::ei_matrix::~ei_matrix()': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/spectral/../numpy_types.h:129: undefined reference to ei_free(void*)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/main.o: in function ei::speechpy::feature::filterbanks(ei::ei_quantized_matrix*, unsigned short, int, unsigned long, unsigned long, unsigned long, bool)': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/dsp/speechpy/feature.hpp:167: undefined reference to ei_free(void*)’
c:/infineon/tools/modustoolbox/tools_2.4/gcc/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:/Users/EthanLiu/mtw/PSOC6_INFERENCE/build/CY8CKIT-062-WIFI-BT/Debug/main.o: in function run_inference': C:\Users\EthanLiu\mtw\PSOC6_INFERENCE/./edge-impulse-sdk/classifier/ei_run_classifier.h:824: undefined reference to ei_read_timer_us()’

17:08:57 Build Failed. 327 errors, 3 warnings. (took 22s.16ms)

The project is :

The errors indicate that ld.exe don’t know how to process the memory, such as:
1、undefined reference to ei_free(void*)
2、undefined reference to ei_calloc(unsigned int, unsigned int)
3、undefined reference to ei_malloc(unsigned int)
4、undefined reference to ei_printf(char const*, …)
5、undefined reference to ei_read_timer_us()

Hi @psoc6now,

The ei_free(), ei_calloc()… functions are target specific. Our C++ library contains definitions for the different official targets we support, see: https://github.com/edgeimpulse/inferencing-sdk-cpp/tree/master/porting.

You’ll probably need to write some of those functions to add support for your board. Which board are you using? As an example you can look at the silabs or ti implementation in the porting directory.

Aurelien

Hi, Aurel
Thanks for your advice , the problem has been solved perfectly :+1:
Ethan