Adding `--version` flag fails the build of `Adafruit_NeoPixel` library

It builds and works fine without that flag, but when I use this ini file:

[env:adafruit_qtpy_esp32c3]
platform = espressif32
board = adafruit_qtpy_esp32c3
framework = arduino
monitor_speed = 115200
build_unflags = -std=gnu++11
build_flags = 
  -std=gnu++2a
  --version
lib_deps = 
	adafruit/Adafruit NeoPixel@^1.10.5
	mikalhart/Streaming@^1.0.0
	paulstoffregen/Encoder@^1.4.2

I get this error:

Processing adafruit_qtpy_esp32c3 (platform: espressif32; board: adafruit_qtpy_esp32c3; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/adafruit_qtpy_esp32c3.html
PLATFORM: Espressif 32 (4.4.0) > Adafruit QT Py ESP32-C3
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20003.0 (2.0.3) 
 - tool-esptoolpy @ 1.30300.0 (3.3.0) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 35 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Adafruit NeoPixel @ 1.10.5
|-- Streaming @ 1.0.0
|-- Encoder @ 1.4.2
Building in release mode
Compiling .pio/build/adafruit_qtpy_esp32c3/src/main.cpp.o
riscv32-esp-elf-g++ (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Generating partitions .pio/build/adafruit_qtpy_esp32c3/partitions.bin
Compiling .pio/build/adafruit_qtpy_esp32c3/lib756/Adafruit NeoPixel/Adafruit_NeoPixel.cpp.o
riscv32-esp-elf-g++ (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling .pio/build/adafruit_qtpy_esp32c3/lib756/Adafruit NeoPixel/esp.c.o
riscv32-esp-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling .pio/build/adafruit_qtpy_esp32c3/lib756/Adafruit NeoPixel/esp8266.c.o
Compiling .pio/build/adafruit_qtpy_esp32c3/lib756/Adafruit NeoPixel/kendyte_k210.c.o
riscv32-esp-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

riscv32-esp-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Archiving .pio/build/adafruit_qtpy_esp32c3/lib756/libAdafruit NeoPixel.a
riscv32-esp-elf-ar: .pio/build/adafruit_qtpy_esp32c3/lib756/Adafruit NeoPixel/Adafruit_NeoPixel.cpp.o: No such file or directory
Compiling .pio/build/adafruit_qtpy_esp32c3/lib23c/Encoder/Encoder.cpp.o
Archiving .pio/build/adafruit_qtpy_esp32c3/libFrameworkArduinoVariant.a
riscv32-esp-elf-g++ (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Indexing .pio/build/adafruit_qtpy_esp32c3/libFrameworkArduinoVariant.a
Compiling .pio/build/adafruit_qtpy_esp32c3/FrameworkArduino/Esp.cpp.o
riscv32-esp-elf-g++ (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling .pio/build/adafruit_qtpy_esp32c3/FrameworkArduino/FirmwareMSC.cpp.o
riscv32-esp-elf-g++ (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

*** [.pio/build/adafruit_qtpy_esp32c3/lib756/libAdafruit NeoPixel.a] Error 1
Compiling .pio/build/adafruit_qtpy_esp32c3/FrameworkArduino/FunctionalInterrupt.cpp.o
riscv32-esp-elf-g++ (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

================================================ [FAILED] Took 1.10 seconds ================================================

When you add this flag, the compiler just prints its version but never outputs a .o object file or attempts to compile the given .c file, so naturally the subsequent steps like packing object files into .a library fails. This completely, but understandly, breaks the build. Why did you want to add this flag?

1 Like

Makes sense, thank you. I wanted to see what C++ version flag is actually used by the compiler. I’m not sure if build_unflags is really necessary, given the next line in my ini file:

build_unflags = -std=gnu++11
build_flags = -std=gnu++2a

I didn’t see it with --verbose flag.

The right way to check if your wanted compiler flags are being used is to use the project task Advanced → Verbose Build, or pio run -v -j1 on the CLI.

1 Like