1. Here, is my real ambient (main.cpp file), trying to include tinyexpr C library. Yes, I need to declare app_main() as extern to compile .cpp. I believe the problem is here, but I can't remove extern "C" of app_main() .I've done dozens of tests, removing extern, including .c and so on...
Code: Select all
extern "C"
{
#include "tinyexpr/tinyexpr.h"
}
extern "C" void app_main()
{
printf("%f\n", te_interp("5*5", 0)); /* Prints 25. */
}
2. Here, is my test ambient (main.c file) and work nicelly. I made this test only to know if library work.
Code: Select all
#include "tinyexpr/tinyexpr.h"
#include "tinyexpr/tinyexpr.c"
void app_main()
{
printf("%f\n", te_interp("5*5", 0)); /* Prints 25. */
}
Output error when main.cpp:
Code: Select all
/build/main/libmain.a(main.o):(.literal.app_main+0x10): undefined reference to `te_interp'
/build/main/libmain.a(main.o): In function `app_main':
/main/main.cpp:9878: undefined reference to `te_interp'
collect2: error: ld returned 1 exit status
make: *** [/esp-idf/make/project.mk:517: /build/esp32.elf] Error 1