undefined reference to task functions in separate components

florent92
Posts: 3
Joined: Fri Mar 06, 2020 2:34 pm

undefined reference to task functions in separate components

Postby florent92 » Sun Jan 03, 2021 11:40 pm

I'm porting an open source project from ESP3.x to to the last ESP-IDF 4.3-dev version.
The full repository is available at:
https://github.com/fc92/ESP32_MP3_Decod ... f-v4.3-dev
(git submodule update --init --recursive is also required to get the full code)

Compilation works but I still have some linker issue :

Code: Select all

idf.py build
Executing action: all (aliases: build)
Running ninja in directory /home/f/esp/ESP32_MP3_Decoder/build
Executing "ninja all"...
[1/5] Performing build step for 'bootloader'
ninja: no work to do.
[2/3] Linking CXX executable esp32_mp3_decoder.elf
FAILED: esp32_mp3_decoder.elf 
: && /home/f/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++  -mlongcalls -Wno-frame-address   CMakeFiles/esp32_mp3_decoder.elf.dir/project_elf_src.c.obj  -o esp32_mp3_decoder.elf  esp-idf/xtensa/libxtensa.a  esp-idf/mbedtls/libmbedtls.a  esp-idf/efuse/libefuse.a  esp-idf/bootloader_support/libbootloader_support.a  esp-idf/app_update/libapp_update.a  esp-idf/esp_ipc/libesp_ipc.a  esp-idf/spi_flash/libspi_flash.a  esp-idf/esp_system/libesp_system.a  esp-idf/soc/libsoc.a  esp-idf/vfs/libvfs.a  esp-idf/esp_eth/libesp_eth.a  esp-idf/tcpip_adapter/libtcpip_adapter.a  esp-idf/esp_netif/libesp_netif.a  esp-idf/esp_event/libesp_event.a  esp-idf/wpa_supplicant/libwpa_supplicant.a  esp-idf/nvs_flash/libnvs_flash.a  esp-idf/esp_wifi/libesp_wifi.a  esp-idf/lwip/liblwip.a  esp-idf/log/liblog.a  esp-idf/heap/libheap.a  esp-idf/esp_ringbuf/libesp_ringbuf.a  esp-idf/driver/libdriver.a  esp-idf/pthread/libpthread.a  esp-idf/espcoredump/libespcoredump.a  esp-idf/perfmon/libperfmon.a  esp-idf/esp32/libesp32.a  esp-idf/esp_common/libesp_common.a  esp-idf/esp_timer/libesp_timer.a  esp-idf/freertos/libfreertos.a  esp-idf/newlib/libnewlib.a  esp-idf/cxx/libcxx.a  esp-idf/app_trace/libapp_trace.a  esp-idf/asio/libasio.a  esp-idf/bt/libbt.a  esp-idf/cbor/libcbor.a  esp-idf/coap/libcoap.a  esp-idf/console/libconsole.a  esp-idf/nghttp/libnghttp.a  esp-idf/esp-tls/libesp-tls.a  esp-idf/esp_adc_cal/libesp_adc_cal.a  esp-idf/esp_gdbstub/libesp_gdbstub.a  esp-idf/esp_hid/libesp_hid.a  esp-idf/tcp_transport/libtcp_transport.a  esp-idf/esp_http_client/libesp_http_client.a  esp-idf/esp_http_server/libesp_http_server.a  esp-idf/esp_https_ota/libesp_https_ota.a  esp-idf/protobuf-c/libprotobuf-c.a  esp-idf/protocomm/libprotocomm.a  esp-idf/mdns/libmdns.a  esp-idf/esp_local_ctrl/libesp_local_ctrl.a  esp-idf/sdmmc/libsdmmc.a  esp-idf/esp_serial_slave_link/libesp_serial_slave_link.a  esp-idf/esp_websocket_client/libesp_websocket_client.a  esp-idf/expat/libexpat.a  esp-idf/wear_levelling/libwear_levelling.a  esp-idf/fatfs/libfatfs.a  esp-idf/freemodbus/libfreemodbus.a  esp-idf/jsmn/libjsmn.a  esp-idf/json/libjson.a  esp-idf/libsodium/liblibsodium.a  esp-idf/mqtt/libmqtt.a  esp-idf/openssl/libopenssl.a  esp-idf/spiffs/libspiffs.a  esp-idf/ulp/libulp.a  esp-idf/unity/libunity.a  esp-idf/wifi_provisioning/libwifi_provisioning.a  esp-idf/main/libmain.a  esp-idf/MerusAudio/libMerusAudio.a  esp-idf/url_parser/liburl_parser.a  esp-idf/http/libhttp.a  esp-idf/fifo/libfifo.a  esp-idf/common/libcommon.a  esp-idf/controls/libcontrols.a  esp-idf/libfaad/liblibfaad.a  esp-idf/libm4a/liblibm4a.a  esp-idf/audio_renderer/libaudio_renderer.a  esp-idf/libfaad_decoder/liblibfaad_decoder.a  esp-idf/fdk-aac/libfdk-aac.a  esp-idf/fdk-aac_decoder/libfdk-aac_decoder.a  esp-idf/mad/libmad.a  esp-idf/mp3_decoder/libmp3_decoder.a  esp-idf/audio_player/libaudio_player.a  esp-idf/inih_port/libinih_port.a  esp-idf/vector/libvector.a  esp-idf/playlist/libplaylist.a  esp-idf/user_driver/libuser_driver.a  esp-idf/ui/libui.a  esp-idf/web_radio/libweb_radio.a  -Wl,--cref -Wl,--Map=/home/f/esp/ESP32_MP3_Decoder/build/esp32_mp3_decoder.map  -fno-rtti  -fno-lto  esp-idf/main/libmain.a  esp-idf/fifo/libfifo.a  esp-idf/common/libcommon.a  esp-idf/libm4a/liblibm4a.a  esp-idf/audio_renderer/libaudio_renderer.a  esp-idf/libfaad_decoder/liblibfaad_decoder.a  esp-idf/fdk-aac_decoder/libfdk-aac_decoder.a  esp-idf/mp3_decoder/libmp3_decoder.a  esp-idf/audio_player/libaudio_player.a  esp-idf/playlist/libplaylist.a  esp-idf/web_radio/libweb_radio.a  esp-idf/asio/libasio.a  esp-idf/cbor/libcbor.a  esp-idf/coap/libcoap.a  esp-idf/esp_adc_cal/libesp_adc_cal.a  esp-idf/esp_gdbstub/libesp_gdbstub.a  esp-idf/esp_hid/libesp_hid.a  esp-idf/esp_https_ota/libesp_https_ota.a  esp-idf/esp_local_ctrl/libesp_local_ctrl.a  esp-idf/esp_serial_slave_link/libesp_serial_slave_link.a  esp-idf/esp_websocket_client/libesp_websocket_client.a  esp-idf/expat/libexpat.a  esp-idf/fatfs/libfatfs.a  esp-idf/sdmmc/libsdmmc.a  esp-idf/wear_levelling/libwear_levelling.a  esp-idf/freemodbus/libfreemodbus.a  esp-idf/jsmn/libjsmn.a  esp-idf/libsodium/liblibsodium.a  esp-idf/mqtt/libmqtt.a  esp-idf/openssl/libopenssl.a  esp-idf/spiffs/libspiffs.a  esp-idf/unity/libunity.a  esp-idf/wifi_provisioning/libwifi_provisioning.a  esp-idf/protocomm/libprotocomm.a  esp-idf/bt/libbt.a  -L/home/f/esp/esp-idf/components/bt/controller/lib  -lbtdm_app  esp-idf/protobuf-c/libprotobuf-c.a  esp-idf/mdns/libmdns.a  esp-idf/console/libconsole.a  esp-idf/json/libjson.a  esp-idf/ui/libui.a  esp-idf/user_driver/libuser_driver.a  esp-idf/MerusAudio/libMerusAudio.a  esp-idf/libfaad/liblibfaad.a  esp-idf/fdk-aac/libfdk-aac.a  esp-idf/mad/libmad.a  esp-idf/inih_port/libinih_port.a  esp-idf/url_parser/liburl_parser.a  esp-idf/http/libhttp.a  esp-idf/url_parser/liburl_parser.a  esp-idf/http/libhttp.a  esp-idf/controls/libcontrols.a  esp-idf/vector/libvector.a  esp-idf/xtensa/libxtensa.a  esp-idf/mbedtls/libmbedtls.a  esp-idf/efuse/libefuse.a  esp-idf/bootloader_support/libbootloader_support.a  esp-idf/app_update/libapp_update.a  esp-idf/esp_ipc/libesp_ipc.a  esp-idf/spi_flash/libspi_flash.a  esp-idf/esp_system/libesp_system.a  esp-idf/soc/libsoc.a  esp-idf/vfs/libvfs.a  esp-idf/esp_eth/libesp_eth.a  esp-idf/tcpip_adapter/libtcpip_adapter.a  esp-idf/esp_netif/libesp_netif.a  esp-idf/esp_event/libesp_event.a  esp-idf/wpa_supplicant/libwpa_supplicant.a  esp-idf/nvs_flash/libnvs_flash.a  esp-idf/esp_wifi/libesp_wifi.a  esp-idf/lwip/liblwip.a  esp-idf/log/liblog.a  esp-idf/heap/libheap.a  esp-idf/esp_ringbuf/libesp_ringbuf.a  esp-idf/driver/libdriver.a  esp-idf/pthread/libpthread.a  esp-idf/espcoredump/libespcoredump.a  esp-idf/perfmon/libperfmon.a  esp-idf/esp32/libesp32.a  esp-idf/esp_common/libesp_common.a  esp-idf/esp_timer/libesp_timer.a  esp-idf/freertos/libfreertos.a  esp-idf/newlib/libnewlib.a  esp-idf/cxx/libcxx.a  esp-idf/app_trace/libapp_trace.a  esp-idf/nghttp/libnghttp.a  esp-idf/esp-tls/libesp-tls.a  esp-idf/tcp_transport/libtcp_transport.a  esp-idf/esp_http_client/libesp_http_client.a  esp-idf/esp_http_server/libesp_http_server.a  esp-idf/ulp/libulp.a  esp-idf/mbedtls/mbedtls/library/libmbedtls.a  esp-idf/mbedtls/mbedtls/library/libmbedcrypto.a  esp-idf/mbedtls/mbedtls/library/libmbedx509.a  esp-idf/soc/soc/esp32/libsoc_esp32.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libcoexist.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libcore.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libespnow.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libmesh.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libnet80211.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libpp.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/librtc.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libsmartconfig.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libphy.a  esp-idf/xtensa/libxtensa.a  esp-idf/mbedtls/libmbedtls.a  esp-idf/efuse/libefuse.a  esp-idf/bootloader_support/libbootloader_support.a  esp-idf/app_update/libapp_update.a  esp-idf/esp_ipc/libesp_ipc.a  esp-idf/spi_flash/libspi_flash.a  esp-idf/esp_system/libesp_system.a  esp-idf/soc/libsoc.a  esp-idf/vfs/libvfs.a  esp-idf/esp_eth/libesp_eth.a  esp-idf/tcpip_adapter/libtcpip_adapter.a  esp-idf/esp_netif/libesp_netif.a  esp-idf/esp_event/libesp_event.a  esp-idf/wpa_supplicant/libwpa_supplicant.a  esp-idf/nvs_flash/libnvs_flash.a  esp-idf/esp_wifi/libesp_wifi.a  esp-idf/lwip/liblwip.a  esp-idf/log/liblog.a  esp-idf/heap/libheap.a  esp-idf/esp_ringbuf/libesp_ringbuf.a  esp-idf/driver/libdriver.a  esp-idf/pthread/libpthread.a  esp-idf/espcoredump/libespcoredump.a  esp-idf/perfmon/libperfmon.a  esp-idf/esp32/libesp32.a  esp-idf/esp_common/libesp_common.a  esp-idf/esp_timer/libesp_timer.a  esp-idf/freertos/libfreertos.a  esp-idf/newlib/libnewlib.a  esp-idf/cxx/libcxx.a  esp-idf/app_trace/libapp_trace.a  esp-idf/nghttp/libnghttp.a  esp-idf/esp-tls/libesp-tls.a  esp-idf/tcp_transport/libtcp_transport.a  esp-idf/esp_http_client/libesp_http_client.a  esp-idf/esp_http_server/libesp_http_server.a  esp-idf/ulp/libulp.a  esp-idf/mbedtls/mbedtls/library/libmbedtls.a  esp-idf/mbedtls/mbedtls/library/libmbedcrypto.a  esp-idf/mbedtls/mbedtls/library/libmbedx509.a  esp-idf/soc/soc/esp32/libsoc_esp32.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libcoexist.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libcore.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libespnow.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libmesh.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libnet80211.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libpp.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/librtc.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libsmartconfig.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libphy.a  esp-idf/xtensa/libxtensa.a  esp-idf/mbedtls/libmbedtls.a  esp-idf/efuse/libefuse.a  esp-idf/bootloader_support/libbootloader_support.a  esp-idf/app_update/libapp_update.a  esp-idf/esp_ipc/libesp_ipc.a  esp-idf/spi_flash/libspi_flash.a  esp-idf/esp_system/libesp_system.a  esp-idf/soc/libsoc.a  esp-idf/vfs/libvfs.a  esp-idf/esp_eth/libesp_eth.a  esp-idf/tcpip_adapter/libtcpip_adapter.a  esp-idf/esp_netif/libesp_netif.a  esp-idf/esp_event/libesp_event.a  esp-idf/wpa_supplicant/libwpa_supplicant.a  esp-idf/nvs_flash/libnvs_flash.a  esp-idf/esp_wifi/libesp_wifi.a  esp-idf/lwip/liblwip.a  esp-idf/log/liblog.a  esp-idf/heap/libheap.a  esp-idf/esp_ringbuf/libesp_ringbuf.a  esp-idf/driver/libdriver.a  esp-idf/pthread/libpthread.a  esp-idf/espcoredump/libespcoredump.a  esp-idf/perfmon/libperfmon.a  esp-idf/esp32/libesp32.a  esp-idf/esp_common/libesp_common.a  esp-idf/esp_timer/libesp_timer.a  esp-idf/freertos/libfreertos.a  esp-idf/newlib/libnewlib.a  esp-idf/cxx/libcxx.a  esp-idf/app_trace/libapp_trace.a  esp-idf/nghttp/libnghttp.a  esp-idf/esp-tls/libesp-tls.a  esp-idf/tcp_transport/libtcp_transport.a  esp-idf/esp_http_client/libesp_http_client.a  esp-idf/esp_http_server/libesp_http_server.a  esp-idf/ulp/libulp.a  esp-idf/mbedtls/mbedtls/library/libmbedtls.a  esp-idf/mbedtls/mbedtls/library/libmbedcrypto.a  esp-idf/mbedtls/mbedtls/library/libmbedx509.a  esp-idf/soc/soc/esp32/libsoc_esp32.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libcoexist.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libcore.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libespnow.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libmesh.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libnet80211.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libpp.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/librtc.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libsmartconfig.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libphy.a  esp-idf/xtensa/libxtensa.a  esp-idf/mbedtls/libmbedtls.a  esp-idf/efuse/libefuse.a  esp-idf/bootloader_support/libbootloader_support.a  esp-idf/app_update/libapp_update.a  esp-idf/esp_ipc/libesp_ipc.a  esp-idf/spi_flash/libspi_flash.a  esp-idf/esp_system/libesp_system.a  esp-idf/soc/libsoc.a  esp-idf/vfs/libvfs.a  esp-idf/esp_eth/libesp_eth.a  esp-idf/tcpip_adapter/libtcpip_adapter.a  esp-idf/esp_netif/libesp_netif.a  esp-idf/esp_event/libesp_event.a  esp-idf/wpa_supplicant/libwpa_supplicant.a  esp-idf/nvs_flash/libnvs_flash.a  esp-idf/esp_wifi/libesp_wifi.a  esp-idf/lwip/liblwip.a  esp-idf/log/liblog.a  esp-idf/heap/libheap.a  esp-idf/esp_ringbuf/libesp_ringbuf.a  esp-idf/driver/libdriver.a  esp-idf/pthread/libpthread.a  esp-idf/espcoredump/libespcoredump.a  esp-idf/perfmon/libperfmon.a  esp-idf/esp32/libesp32.a  esp-idf/esp_common/libesp_common.a  esp-idf/esp_timer/libesp_timer.a  esp-idf/freertos/libfreertos.a  esp-idf/newlib/libnewlib.a  esp-idf/cxx/libcxx.a  esp-idf/app_trace/libapp_trace.a  esp-idf/nghttp/libnghttp.a  esp-idf/esp-tls/libesp-tls.a  esp-idf/tcp_transport/libtcp_transport.a  esp-idf/esp_http_client/libesp_http_client.a  esp-idf/esp_http_server/libesp_http_server.a  esp-idf/ulp/libulp.a  esp-idf/mbedtls/mbedtls/library/libmbedtls.a  esp-idf/mbedtls/mbedtls/library/libmbedcrypto.a  esp-idf/mbedtls/mbedtls/library/libmbedx509.a  esp-idf/soc/soc/esp32/libsoc_esp32.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libcoexist.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libcore.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libespnow.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libmesh.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libnet80211.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libpp.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/librtc.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libsmartconfig.a  /home/f/esp/esp-idf/components/esp_wifi/lib/esp32/libphy.a  /home/f/esp/esp-idf/components/xtensa/esp32/libhal.a  -u esp_app_desc  -L /home/f/esp/esp-idf/components/esp_rom/esp32/ld  -T esp32.rom.newlib-time.ld  -T esp32.rom.ld  -T esp32.rom.libgcc.ld  -T esp32.rom.newlib-data.ld  -T esp32.rom.syscalls.ld  -T esp32.rom.newlib-funcs.ld  -u vfs_include_syscalls_impl  -L /home/f/esp/esp-idf/components/esp_wifi/lib/esp32  -u pthread_include_pthread_impl  -u pthread_include_pthread_cond_impl  -u pthread_include_pthread_local_storage_impl  -L /home/f/esp/ESP32_MP3_Decoder/build/esp-idf/esp32  -T esp32_out.ld  -u app_main  -L /home/f/esp/ESP32_MP3_Decoder/build/esp-idf/esp32/ld  -T esp32.project.ld  -L /home/f/esp/esp-idf/components/esp32/ld  -T esp32.peripherals.ld  -u call_user_start_cpu0  -u ld_include_panic_highint_hdl  -Wl,--gc-sections  -Wl,--undefined=uxTopUsedPriority  -lm  esp-idf/newlib/libnewlib.a  -u newlib_include_locks_impl  -u newlib_include_heap_impl  -u newlib_include_syscalls_impl  -u newlib_include_pthread_impl  -lgcc  -u __cxa_guard_dummy  -lstdc++  esp-idf/pthread/libpthread.a  -u __cxx_fatal_exception  esp-idf/app_trace/libapp_trace.a  -lgcov  esp-idf/app_trace/libapp_trace.a  -lgcov  -lc && :
/home/f/.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: esp-idf/audio_player/libaudio_player.a(audio_player.c.obj):(.literal.start_decoder_task+0x8): undefined reference to `fdkaac_decoder_task'
/home/f/.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: esp-idf/audio_player/libaudio_player.a(audio_player.c.obj):(.literal.start_decoder_task+0x14): undefined reference to `libfaac_decoder_task'
/home/f/.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: esp-idf/audio_player/libaudio_player.a(audio_player.c.obj):(.literal.start_decoder_task+0x20): undefined reference to `mp3_decoder_task'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
The 3 references correspond to task functions implemented in separate components.

I removed cyclic dependencies, checked that the components are listed in PRIV_REQUIRES using the default components directory tree, checked that the functions are not defined or implemented static. Also I found the compiled static libraries like esp-idf/mp3_decoder/libmp3_decoder.a with references required.

Any help to solve this issue would be appreciated.

florent92
Posts: 3
Joined: Fri Mar 06, 2020 2:34 pm

Re: undefined reference to task functions in separate components

Postby florent92 » Fri Jan 15, 2021 10:13 pm

I managed to get rid of this linker issue by removing some dependencies. Still not very clear how to avoid this kind of issue.
The project now compiles and work with ESP-IDF v4.3-dev : https://github.com/fc92/ESP32_MP3_Decoder

funkydunky
Posts: 6
Joined: Thu Feb 06, 2020 10:19 pm

Re: undefined reference to task functions in separate components

Postby funkydunky » Tue Mar 01, 2022 9:45 pm

better late than never.

i did exactly the same as you and had the same troubles. i got rid of this linker problem with


set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 4)

in the decoder components

Who is online

Users browsing this forum: No registered users and 166 guests