Skip to content

ESP8266: a sketch using a bundled core library (ESP8266WiFi) fails at link; library sources are never compiled (2.5.51) #1994

Closed

Description

@stevenmunn312-tech

Summary

On fbuild 2.5.51, an ESP8266 sketch that includes one of the core's bundled libraries (ESP8266WiFi, ESP8266WebServer, ESP8266mDNS, WiFiUdp) compiles and then fails to link, with undefined references to that library's symbols. A sketch with no such include builds, deploys and runs: a LOLIN D1 mini flashed through fbuild deploy on 2.5.51 works. Arduino CLI builds the same Wi-Fi sketches.

Reproduce

platformio.ini:

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino

src/main.ino:

#include <ESP8266WiFi.h>

void setup() {
  WiFi.mode(WIFI_STA);
  WiFi.begin("ssid", "password");
}

void loop() {}
$ fbuild <project> build -e nodemcuv2 --no-timestamp
Board: NodeMCU 1.0 (ESP-12E Module) / ESP8266 @ 80MHz
Compiled 1/1 files
Compiled 83/83 files
Linking firmware.elf
build error: build failed: xtensa-lx106-elf-gcc link failed:
undefined reference to `WiFi'
undefined reference to `_ZN19ESP8266WiFiSTAClass5beginEPKcS1_iPKhb'
undefined reference to `_ZN23ESP8266WiFiGenericClass4modeE8WiFiMode'
collect2.exe: error: ld returned 1 exit status

The same happens with board = d1_mini, and with ESP8266WebServer.h and ESP8266mDNS.h (undefined WiFiClient, WiFiServer, MDNSResponder, ESP8266WebServerTemplate symbols).

Environment

  • fbuild 2.5.51+git.9b26affea5ad, Windows 11. Also on a GitHub windows-latest runner.
  • framework-arduinoespressif8266 3.1.2, toolchain-xtensa 3.2.0-gcc10.3.

Cause, as far as I can read it at v2.5.51

crates/fbuild-build-esp/src/esp8266/orchestrator.rs:

  • Lines 414-428 add every bundled library's src directory to the include path (// Built-in Arduino libraries (ESP8266WiFi, etc.)), so the sketch compiles against the headers.
  • The build then calls pipeline::run_sequential_build_with_libs(&compiler, &linker, ctx, params, &sources, &[], lib_deps_plan, Some(&lib_env), ...). sources holds the core and the sketch, and extra_link_inputs is empty. Nothing compiles the bundled libraries' .cpp files.

The build tree agrees: .fbuild/build/nodemcuv2/release/ holds core/ and src/ only, and the log shows 83 core files and one sketch file compiled. The ESP32 build selects and compiles framework libraries from the sketch's includes (framework-libs cache: stored N in its log); the ESP8266 build has no such step. run_sequential_build_with_libs delegates to run_sequential_build_with_optional_framework_libs, so the hook may already be there.

Expected

The bundled libraries a sketch's include graph reaches are compiled and linked, as on ESP32.

Activity

  1. added
    bug
    on Nov 11, 2026
  2. zackees commented on Nov 11, 2026

    @zackees
    Member

    Reproduced on Linux and fixed in #1995.

    Confirmed with your repro, board = nodemcuv2, pinned espressif8266 (framework-arduinoespressif8266 3.1.2, xtensa-lx106-elf 3.2.0-gcc10.3): your diagnosis is exactly right — the bundled libraries' include dirs were on the search path, but nothing compiled their sources. fbuild build compiled 83 core + 1 sketch files and then died with the same undefined reference to WiFi / ESP8266WiFiSTAClass::begin.

    Fix (#1995): the ESP8266 orchestrator now runs the same library-dependency finder the Teensy/STM32/RP2040 paths use, seeded from the project's translation units (lib_deps and active #if branches honored), and adds the reached libraries' sources to the core compile set. Unreached libraries are not compiled.

    On the same toolchain after the fix:

    sketch result
    #include <ESP8266WiFi.h> + WiFi.begin(...) build succeeded 22.9 s, flash 262 851 B, 16 ESP8266WiFi sources compiled
    #include <ESP8266WebServer.h> + server.begin() build succeeded 13.7 s, selects ESP8266WebServer + ESP8266WiFi transitively
    plain sketch unchanged, 0 bundled sources

    Thanks for the precise write-up — the file/line pointers made this a one-pass fix. I have not flashed the WiFi image to a LOLIN D1 mini (only the plain sketch runs on hardware here), so if you can re-run your fbuild deploy on 2.5.52+ once #1995 lands, that closes the loop.

  3. stevenmunn312-tech commented on Nov 19, 2026

    @stevenmunn312-tech
    Author

    Sorry for the delay getting this onto the bench.

    Confirmed on hardware with 2.5.52: a LOLIN D1 mini built and flashed through fbuild with a sketch that uses ESP8266WiFi, ESP8266WebServer and ESP8266mDNS.

    • fbuild build -e esp8266_esp8266_d1_mini: linked in 72.6 s, flash 361,311 bytes, RAM 31,676 bytes. No undefined reference to WiFiClient any more.
    • fbuild deploy -p COM8 --skip-build: esptool v5.3.0 wrote 365,408 bytes (263,315 compressed) in 23.7 s, hash verified, hard reset via RTS.
    • On boot the board joined Wi-Fi, answered on mDNS as fastled-board.local, and served its web page. A phone and a desktop browser could both drive the LEDs through it. A POST to the sketch's /set route was applied and read back.

    Thanks for the quick fix in #1995. From our side this one can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions