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

xiaolaba
Posts: 8
Joined: Sat Sep 26, 2020 7:01 am

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

Postby xiaolaba » Sat Sep 26, 2020 7:28 am

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.

ESP_Sprite
Posts: 9769
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Sun Sep 27, 2020 7:18 pm

Your main/CMakeLists.txt is not a valid component CMakelists.txt. (It looks like it's a copy of your project CMakeLists.txt file).

xiaolaba
Posts: 8
Joined: Sat Sep 26, 2020 7:01 am

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

Postby xiaolaba » Tue Sep 29, 2020 4:20 am

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.

ESP_Sprite
Posts: 9769
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Tue Sep 29, 2020 2:04 pm

So do you still get that error using a proper CMakeLists.txt? Or did the error change?

xiaolaba
Posts: 8
Joined: Sat Sep 26, 2020 7:01 am

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

Postby xiaolaba » Wed Sep 30, 2020 1:23 am

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.

Zeni241
Posts: 86
Joined: Tue Nov 20, 2018 4:28 am

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

Postby Zeni241 » Thu Jun 03, 2021 10:58 am

In was getting this error. The reason was void pp_main(void) instead of void app _main(void) :o :?

Who is online

Users browsing this forum: No registered users and 81 guests