undefined reference to `app_main'

oarcher
Posts: 2
Joined: Tue May 07, 2024 4:50 pm

Re: undefined reference to `app_main'

Postby oarcher » Tue May 07, 2024 5:06 pm

I was also facing this issue, when trying to compile cpp files.

check that you have in your top CMakeLists.txt:

Code: Select all

cmake_minimum_required(VERSION 3.6)
set(CMAKE_CXX_STANDARD 17)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(myproj)
And in main/myproj.cpp:

Code: Select all

extern "C" void app_main(void)
{
...
}

striderheng
Posts: 1
Joined: Thu Mar 25, 2021 11:08 am

Re: undefined reference to `app_main'

Postby striderheng » Tue Oct 01, 2024 7:36 am

If you check here, https://docs.espressif.com/projects/esp ... ystem.html
under renaming main component, it gives you instructions if you are not using main.c or main directory.
In my case I am using src directory with main.cpp as the file with my 'main code'

Adding src to the root project Cmakelists file with the below helped.

set(EXTRA_COMPONENT_DIRS src ../commoncomponents )

Also running idf.py reconfigure task (you can find this in VIEW..COMMAND PALETTE) usually helps when you have changes Cmale needs to know about.

if you are coding in CPP, you need to use

extern "C" void app_main(void)

instead of the app_main() for if you are using C

Who is online

Users browsing this forum: No registered users and 50 guests