How to add -lm option to platformio?

Per build_flags docs, adding linker flags should be done with

build_flags = -Wl,-lm

If that does not appear in the final linker output, resort to scripting, as e.g. seen with add_nanolib.py here and here, just with only "-lm" in the array, or env.Append(LIBS=["m"]).

1 Like