Compiling EI model c++ library into existing c ESP32S3 project

Question/Issue:
Hi everyone, i’m running into compiling issues when trying to integrate my EI model into an existing c project.
The starting point is a project created for ESP32S3 written in c using Espressif-IDE (ESP IDF 5.0).
I took the model i created into EI and exported it as a c++ library, i then added the library into the project folder as explained in the EI documentation. However i can’t find a way to make the project compile.
I added the lines from the EI library CMakeList file inside the top level CMakeList file of my project.
The compiling errors i have are the following:

  1. “CMake Error at edge-impulse-sdk/cmake/zephyr/CMakeLists.txt:14 (target_include_directories):
    target_include_directories called with non-compilable target type”

This error referes to the following lines of code:

target_include_directories(app PRIVATE
${EI_SDK_FOLDER}
)

  1. “CMake Error at CMakeLists.txt:34 (target_include_directories):
    target_include_directories called with non-compilable target type”

This error refers to the following line of code:

target_include_directories(app PRIVATE .)

This code is part of the code i copied from the EI library CMakeList file.

Does someone have tried to integrate EI model c++ library into existing c project? Do you have any idea on how to solve this problem? Thank you all

Project ID:

Context/Use case:

Hi @MatteoBraiato,

Please see this example ESP32 project for how to configure your CMakeLists to compile an Edge Impulse project/library with ESP-IDF.

Thank you @shawn_edgeimpulse, the example you shared has been usefull, i made some steps forward.
Now i encountered another compile error: ‘C:/Espressif/tools/xtensa-esp32s3-elf/esp-2022r1-11.2.0/xtensa-esp32s3-elf/xtensa-esp32s3-elf/include/c++/11.2.0/bits/stl_algobase.h:59:10: fatal error: bits/c++config.h: No such file or directory’
I checked into the folder and the file is actually missing.
I tried searching online and some say that it is a cross compiling fault, they suggest to install g+±multilib to solve the problem (g++ - Missing include "bits/c++config.h" when cross compiling 64 bit program on 32 bit in Ubuntu - Stack Overflow)
I’m actually using Espressif-IDE as a coding environment, i have never changed the build toolchain before, do you thing this is necessary or do you have any other suggestions?

I know this isn’t an issue strictly related to edge impulse, but this is the first time i encountered this type of problem, and maybe you have already handled similar issues. Thank you in advance for your help

Hello, @MatteoBraiato !
Yes, this does not look like anything related to our C++ library. I can only give you a few recommendations here:

  1. Avoid using Windows as development environment for C/C++. It makes things unnecessarily complicated. If you do not have a MacOS/Linux machine, the best way is to use WSL.
  2. We have not tested ESP-IDF 5.0 with our C++ library, the only version tested is 4.4.

@MatteoBraiato I probably have 5 different bootable Ubuntu flash drives running various scenarios. This is basically a hardware version of Containers (aka Docker). So my advice is if you do not have an Ubuntu machine you can easily turn your Windows machine into an Ubuntu machine by creating a bootable Ubuntu flash drive (or external HDD or external SSD or external Nvme, etc.) These external storage devices also keep you main system from running out of storage. Some things are much easier to implement on Unix.

2 Likes

Hello everyone and thank you for your help. Here are some updates.
I tried to port my project over to linux (virtual machine) as suggested. Now my setup is:
-OS: Ubuntu 22.04
-Compiling tool: idf.py (command line)

I tried to compile the project however i encountered another error:

“/home/matteo/Documents/coding/espressif/sample_project/edge-impulse-sdk/dsp/memory.hpp:23:10: fatal error: memory: No such file or directory
23 | #include
| ^~~~~~~~
compilation terminated.”

If i comment this line of code another error occours when i try to do “#include ” later in the compilation process.

Since both and are standard c++ library i suppose that somehow the standard c++ library is not ‘detected’ during the compilation, is something you have ever encountered?

Did you make progress since then?
If you have issues compiling our standalone example in Ubuntu, we could go step-by-step to see where things go wrong.