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" : [
"-std=gnu++14",
"-D HSE_CLOCK=8000000 -D DEBUG_BUILD"
],
"extraScript": "scripts/gen_configs.py"
},
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
jaimi5
February 20, 2025, 7:33pm
6
Hi all! I am having the same issue related before. I am working with a platformio library and I need to add and remove some flags. I have this in the library.json.
"build": {
"flags": [
"-std=c++2a",
"-std=gnu++2a"
],
"unflags": [
"-std=gnu++11"
]
},
Despite this, when running pio run -v
, I still see -std=gnu++11
being added to the compilation command.
Does anyone have insights on how to resolve this? Is it worth reopening the GitHub issue?
Thanks in advance for your help!
The compilation command for which file? One of the source files of the library or a totally different file?
jaimi5
February 21, 2025, 1:25pm
8
I am using the library in another project adding it using the Platformio lib_deps attribute.
It happen when compiling this project that uses the library.
What’s that project’s platformio.ini
?
jaimi5
February 22, 2025, 12:58pm
10
Here is the platformio.ini:
[env:ttgo-t-beam]
platform = espressif32
board = ttgo-t-beam
framework = arduino
monitor_speed = 115200
lib_deps =
https://github.com/LoRaMesher/LoRaMesher#new_loramesher