I'm trying to compile a code that uses stl <map> but I'm getting this error:
fatal error: map: No such file or directory
I'm using latest esp-mdf
Cant compile using stl files
Re: Cant compile using stl files
Just to make sure it's not an error on my project, I did a copy of the development_kit/light sample project and simply added a
to the light_example.c file, and then make -j4 flash, I got this output:
Code: Select all
#include <map>
Code: Select all
$ make -j4 flash
Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a5
Compiler version: 5.2.0
Python requirements from D:/esp/esp-mdf/esp-idf/requirements.txt are satisfied.
CC build/main/light_example.o
CC build/mconfig/mconfig_chain.o
CC build/mdns/mdns.o
D:/m10smarthome/light/main/light_example.c:39:15: fatal error: map: No such file or directory
compilation terminated.
Re: Cant compile using stl files
Ok, just found out that I have to name the files as *.cpp if I want to use c++ stuff.
This seems obvious, but I used to code on esp-idf on PlatformIO and I could use c++ libraries and language features on .c files. I thought esp-idf build system compiled everything as c++ by default.
Also, it's woth to mention that after I renamed light_example.c to light_example.cpp I get a compile error on mlink_trigger.h line 83, whith is:
This seems obvious, but I used to code on esp-idf on PlatformIO and I could use c++ libraries and language features on .c files. I thought esp-idf build system compiled everything as c++ by default.
Also, it's woth to mention that after I renamed light_example.c to light_example.cpp I get a compile error on mlink_trigger.h line 83, whith is:
#ifdef __cplusplus
} // HERE
#endif /**< _cplusplus */
Re: Cant compile using stl files
Functions that call C++ directly need to have the file format `cpp` or put `extern "C" in front of the function.
I suggest you: Write the function that needs to use the esp-idf interface in a `cpp` file, and put `extern "C" `. in front of the function. This can be called directly in c.
> Note: If you have questions, you can post the [issue](https://github.com/espressif/esp-mdf/issues) on github
I suggest you: Write the function that needs to use the esp-idf interface in a `cpp` file, and put `extern "C" `. in front of the function. This can be called directly in c.
> Note: If you have questions, you can post the [issue](https://github.com/espressif/esp-mdf/issues) on github
Who is online
Users browsing this forum: No registered users and 32 guests