Linking errors with netif

herhor67
Posts: 9
Joined: Wed Oct 26, 2022 7:56 pm

Linking errors with netif

Postby herhor67 » Thu Dec 19, 2024 6:53 am

Hello everyone,
I used the example `wifi_provisioning` successfully (compiled, flashed, working). I then moved parts of the code to my own project, fixed headers, fixed components REQUIRES (`nvs_flash lwip esp_netif esp_wifi esp_event wifi_provisioning driver`)

Everything is fine, except now I'm getting linker errors related to netif.

Code: Select all

FAILED: VFDClock.elf
FAILED: VFDClock.elf
cmd.exe /C "cd . && D:\Espressif\tools\tools\xtensa-esp-elf\esp-13.2.0_20230928\xtensa-esp-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address  -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero -fno-builtin-stpcpy -fno-builtin-strncpy -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32=0 -Wl,--Map=D:/Espressif/projects/VFD_Clock/build/VFDClock.map -Wl,--no-warn-rwx-segments -fno-rtti -fno-lto -Wl,--gc-sections -Wl,--warn-common -T esp32.peripherals.ld -T esp32.rom.ld -T esp32.rom.api.ld -T esp32.rom.libgcc.ld -T esp32.rom.newlib-data.ld -T esp32.rom.syscalls.ld -T esp32.rom.newlib-funcs.ld -T memory.ld -T sections.ld @CMakeFiles\VFDClock.elf.rsp -o VFDClock.elf  && cd ."
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/esp_wifi/libesp_wifi.a(wifi_default.c.obj):(.literal.wifi_start+0x18): undefined reference to `esp_netif_netstack_buf_free'
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/esp_wifi/libesp_wifi.a(wifi_default.c.obj):(.literal.wifi_start+0x1c): undefined reference to `esp_netif_netstack_buf_ref'
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/esp_wifi/libesp_wifi.a(wifi_default.c.obj):(.literal.esp_netif_create_default_wifi_ap+0x4): undefined reference to `_g_esp_netif_netstack_default_wifi_ap'
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/esp_wifi/libesp_wifi.a(wifi_default.c.obj):(.literal.esp_netif_create_default_wifi_sta+0x4): undefined reference to `_g_esp_netif_netstack_default_wifi_sta'
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/main/libmain.a(main.cpp.obj):(.literal.app_main+0x54): undefined reference to `esp_netif_sntp_init'
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/main/libmain.a(main.cpp.obj):(.literal.app_main+0x58): undefined reference to `esp_netif_sntp_sync_wait'
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/main/libmain.a(main.cpp.obj): in function `app_main':
D:/Espressif/projects/VFD_Clock/main/main.cpp:114:(.text.app_main+0x11d): undefined reference to `esp_netif_sntp_init'
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: D:/Espressif/projects/VFD_Clock/main/main.cpp:121:(.text.app_main+0x126): undefined reference to `esp_netif_sntp_sync_wait'   
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/wifi_provisioning/libwifi_provisioning.a(handlers.c.obj):(.literal.get_status_handler+0x14): undefined reference to `esp_netif_get_handle_from_ifkey'
D:/Espressif/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: esp-idf/wifi_provisioning/libwifi_provisioning.a(handlers.c.obj): in function `get_status_handler':
D:/Espressif/idf/v5.2.2/esp-idf/components/wifi_provisioning/src/handlers.c:57:(.text.get_status_handler+0x4c): undefined reference to `esp_netif_get_handle_from_ifkey'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
And also an error in Problems tab:

Code: Select all

(.text.app_main+0x126): undefined reference to `esp_netif_sntp_sync_wait'
What is going on? Did I miss something?

herhor67
Posts: 9
Joined: Wed Oct 26, 2022 7:56 pm

Re: Linking errors with netif

Postby herhor67 » Thu Dec 19, 2024 8:19 pm

Solved.
In case anyone happens on this or similar error, first (obviously) check if all REQUIRES are present (this will be shown in problems tho as missing headers).
Second is menuconfig -- check nvs, netif, wifi, etc.
I had for some unknown reason, in the netif tcp/ip stack setting, selected "loopback" and not "lwip" which must have caused lwip to not build and fail linking. Geeez.

Who is online

Users browsing this forum: ChatGPT-User, Google [Bot], PerplexityBot, Qwantbot and 4 guests