Undefined reference to `app_main'

When trying to create a blank project, I always get undefined reference to 'app_main'. When I select Arduino as framework it works but not with idf. Maybe it is because of the new idf 5.X version? If yes, how to change that during project setup?

Can you pload your project files? (Without .pio folder)

Using VS Code Version: 1.80.1 (Universal)
Platformio: Core 6.1.9 Home 3.4.4

Can you replace the contents of the src/CMakeLists.txt with

idf_component_register(SRCS "main.c"
                    INCLUDE_DIRS ".")


Sadly gives me the same error:

/esp/esp-idf/components/freertos/port/port_common.c:135: undefined reference to `app_main'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Hi I’m here with the same error. And I’ve googling it for days without any solution.

esp/esp-idf/components/freertos/app_startup.c:206: undefined reference to `app_main’

how can it be that hard to solve this problem ??

I have the main.c file

void app_main(void)
printf(“Hello world!\n”);

sem_vsync_end = xSemaphoreCreateBinary();
sem_frame_buffer_ready = xSemaphoreCreateBinary();


I’ve rename it to app_main.c and app_main.cpp. Everytime I do it. I’ve update the CMake file. PIO and VScode and ESP-IDF all of them are up to date. What do we missing?

This file was automatically generated for projects

without default ‘CMakeLists.txt’ file.


idf_component_register(SRCS ${app_sources})

idf_component_register(SRCS “app_main.cpp”