----------------------------- Delete below -----------------------------
/home/linux/esp32/esp-idf/examples/get-started/ESP32_RC522/build/esp32/libesp32.a(cpu_start.o):(.literal.main_task+0x18): undefined reference to app_main'
/home/linux/esp32/esp-idf/examples/get-started/ESP32_RC522/build/esp32/libesp32.a(cpu_start.o): In functionmain_task':
/home/linux/esp32/esp-idf/components/esp32/cpu_start.c:515: undefined reference to `app_main'
Do you have void app_main() function in any file in your project?
What is yours folders tree looks like?
If you are using Cmake to build your project, make sure your c source filename is included in CMakeLists.txt under the main folder.
set(COMPONENT_SRCS "hello_world_main.c"
"file1.c"
"file2..c")
According to the docs a CMakeLists.txt file isn't needed under the
Hi @f00bard , that part of the docs is outdated, will fix. main should be treated like any other component, with its own CMakeLists.txt.
Hi, @tutuwin
Have you solved this issue?
thanks !!
@tutuwin Closing as there are no updates to the last question by @koobest.
Hi @renzbagaporo ,
I am running in the same kind of problem.

This problem is happening to me because I'm trying to work in c++ with Esp-IDF V4.0 so I renamed the main.c with main.cpp and did the same in the CMakeList.txt.
It work for some time but then the library becomes "unresolved including" and this errors comes with it some time.
I don't totally understand this erros and would like to know of a fix that is good for more then a day.
Thanks
Did you add:
extern "C" void app_main()
I tried it last week and it did'nt work but this time it did.
But new problem,

It's a C main so can't use any C++ stuff.
It's a more basic problem but could someone help me. I found so little information on this and when I did I'm not sure if it's still good or expired since I'm on ESP-IDF V4.0
Also, I don't have the compiler error but since it still compile my code in C, it does'nt recognize the include in the class.


Have you added spi.cpp to the list of source files @Arag0to?
I tried it last week and it did'nt work but this time it did.
But new problem,main.cpp
It's a C main so can't use any C++ stuff.
It's a more basic problem but could someone help me. I found so little information on this and when I did I'm not sure if it's still good or expired since I'm on ESP-IDF V4.0Also, I don't have the compiler error but since it still compile my code in C, it does'nt recognize the include in the class.
spi.h
spi.cpp
I have exactly the same issue. I'trying to add an external class (cpp + h). As I'm a beginner in cmake (coming from Visual Studio), can anyone tell me how to include source and header files correctly to project? Thanks a lot.
Most helpful comment
Did you add:
extern "C" void app_main()