I experience some difficulties trying to add an Impulse to my VS Code project for a Zephyr-based custom board (based on nrf9160). When I build multiple errors arise, but the first one is from numpy.hpp: cfloat: No such file or directory.
My project is configured with main.c, I know this is a problem, but it’s not clear to me how I should convert all of my .c files properly. So that I can compile with a C++ compiler (i.e. zephyr toolchain)
So far I have:
- installed a sufficient nrf SDK version (2.2.0)
- Merged the configuration from the example-standalone-inferencing-zephyr as best as I could:
I managed to build example-standalone-inferencing-zephyr after adding my board, application overlay and prj.conf files.
What I find strange is that I can find cfloat, memory, etc. in my zephyr toolchain dir. Why won’t my compiler find those files and instead raise an error.
Thank you in advance.
Oh wow I finally got it all working today. prj_team = happy;
This is for all the desperate newbies out there like me.
I found this worked:
- First make sure all dependencies are met, so install a nrf SDK >= 1.6.0 using the nrf connect tool manager.
- Install all necessary VS Code extensions to help you aid in the debugging & build config process (nrf, Cmake, C/C++, Kconfig, etc.)
- Just merge the CmakeList.txt, prj.conf, etc. files from the example-standalone-inferencing-zephyr-master project with my project files.
- If you have to mix C & C++: Just only convert the .c files that include the EI SDK directly. I did not have to convert my main.c, but rather the .c file that was referenced by main.c and actually #included you Edge_impulse. This was at first confusing to me, since all documentation by EI and NRF says you need a C++ project with main.cpp, which is not the case necessarily .
This is why the compiler was throwing: “did not found ”, it was compiling the EI libraries with a C compiler, because my file was named “car_sensor.c”. When I changed the file extension to .cpp all worked. Sounds so obvious now -.-
- This guide was useful to convert .c and .h files for different C->C++ or C+±>C function references: https://isocpp.org/wiki/faq/mixing-c-and-cpp
Thanks to everyone from Edge Impulse, great platform.
Glad to hear you got it working, and thank you for putting your notes here to help others!
Hi, can you share the main structure of this implementation? No your code, just the way you implemented the c++ library in your project.
You mean actual file structure?
I already had a magnetomer.c file, which I used to drive a magnetometer. I changed the name of this file to magnetometer.cpp. And used the guide I linked earlier.
Is this what you mean?