PlatformIO Community

Library.json ignored build.unflags

Hi all,

I’m building a platformio library that needs to remove some flags for the compilation process to run successfully.

Here’s the Build part inside library.json

"build" : {
        "unflags": ["-std=gnu++98", "-std=c++11"],
        "flags" : [
            "-D HSE_CLOCK=8000000 -D DEBUG_BUILD"
        "extraScript": "scripts/"

The compilation fails and if in the script I dump the scons evironment to check if it’s working and I can’t see the BUILD_UNFLAGS field.

If in the platformio.ini of the project that is using the library I add the following line everything is working perfectly:

build_unflags = -std=gnu++98 -std=c++11

is it a bug or am I doing it wrong?

It may be that the unflags only applies when building the source code of that specific library?

Otherwise, try upgrading your core version (cli + pio upgrade --dev) and retry. If it still doesn’t work, seek guidance at Issues · platformio/platformio-core · GitHub.

I tried with the upgrade and it didn’t work, so I opened an Issue.

I don’t get what you mean. The project should be compiling the library source code.

I meant there might be difference between the flags being applied when the sources in src/ are compiled vs the one in the library in lib/ etc.

Ah, ok. Checked. There is no difference.

1 Like