Page 1 of 1

ESP-IDF v4.1, cpu_start.c:551: undefined reference to `app_main'

Posted: Sat Sep 26, 2020 7:28 am
by xiaolaba
hi, need help there to understand cause and looking for solution.

The hello_world build under ESP-IDF v4.1 has been done and fine, so we know the build tool chain and setup has been done perfectly.

we has try to build the project ESP32_MP3_Decoder, failed and log shows following


[Codebox]
c:/users/user0/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/esp32/libesp32.a(cpu_start.c.obj):(.literal.main_task+0x18): undefined reference to `app_main'
c:/users/user0/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/esp32/libesp32.a(cpu_start.c.obj): in function `main_task':
C:/Users/user0/esp/components/esp32/cpu_start.c:551: undefined reference to `app_main'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
[/Codebox]


The project & log is hosted at Github,
https://github.com/xiaolaba/ESP32_MP3_Decoder

appreciate your help.

Re: ESP-IDF v4.1, cpu_start.c:551: undefined reference to `app_main'

Posted: Sun Sep 27, 2020 7:18 pm
by ESP_Sprite
Your main/CMakeLists.txt is not a valid component CMakelists.txt. (It looks like it's a copy of your project CMakeLists.txt file).

Re: ESP-IDF v4.1, cpu_start.c:551: undefined reference to `app_main'

Posted: Tue Sep 29, 2020 4:20 am
by xiaolaba
yes, your are absolute right. that was one of trial and error to see whether be able port the project and hopefully to remove the compilation error, but it turned out the same error produced by linker.

Re: ESP-IDF v4.1, cpu_start.c:551: undefined reference to `app_main'

Posted: Tue Sep 29, 2020 2:04 pm
by ESP_Sprite
So do you still get that error using a proper CMakeLists.txt? Or did the error change?

Re: ESP-IDF v4.1, cpu_start.c:551: undefined reference to `app_main'

Posted: Wed Sep 30, 2020 1:23 am
by xiaolaba
thanks for your help.
there were three options experimented to the builds, moved CMakeLists.txt back and forth, one folder at a time existed only, or put them all.

Code: Select all

ESP32_MP3_Decoder\main\CMakeLists.txt
ESP32_MP3_Decoder\CMakeLists.txt
It does not matter where we put the CMakeLists.txt, still the same error.
we are new to cmake, so just scratching head hard and to try and want to know why.

Re: ESP-IDF v4.1, cpu_start.c:551: undefined reference to `app_main'

Posted: Thu Jun 03, 2021 10:58 am
by Zeni241
In was getting this error. The reason was void pp_main(void) instead of void app _main(void) :o :?