PlatformIO Community

FreeRTOS port_common.c can't find app_main.c

Hello PlatformIO Community,

I am running into issues trying to compile the sample esp32_blink project that uses the ESP-IDF with PlatformIO.

Everything links fine it looks like, as I can control-click to all the functions and files, but right when the build is about to finish it errors out with: C:/Users/user/esp/esp-idf/components/freertos/port/port_common.c:125: undefined reference to 'app_main'

I am not the first one to run into this, others have suggested adding extern "C" before the void app_main, but that’s for cpp files, but I am using only C (I tried it anyways and it didn’t work). I am not doing anything special, as my code is straight from the example.

I am really stuck here as I am using the stock example so I shouldn’t have to modify anything; the CMakeLists in the src directory looks like it is including the main.c correctly.

I am using the latest stable version of ESP-IDF, 4.4

Any help or insight would be much appreciated.

Thank you!


Where is the source file located? Did you reference its file name in the src/CMakeLists.txt like the example? Seems like the main.c isn’t compiled at all to me.

My source file is located in the src directory. It seems that my CMakeLists was auto generated to look like this:

FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)

idf_component_register(SRCS ${app_sources})

When I changed it to what you proposed, it still didn’t work, perhaps its because of the CMakeLists at the root of my project? It looks like this:

cmake_minimum_required(VERSION 3.16.0)



I am assuming the environment variable IDF_PATH is properly defined, although idk how to verify this.

Do any of these look incorrect?

Thank you

Can you upload the whole project to github for cross verification?