PlatformIO Community

PIO issue: Clashing includes - working in Arduino IDE

In a fairly simple setup there is an issue with includes getting mixed up that does not happen in the Arduino IDE. Minimum working example:

platformio.ini:

[env:nucleo_l053r8]
platform = ststm32
board = nucleo_l053r8
framework = arduino

lib_deps = nrf24/RF24Ethernet@1.6.8

Both ststm32 and the RF24Ethernet library include “timer.h”. Both reference a different file though.
Some might argue that the names should be unique, but I doubt this is realistic in large projects with lots of libraries.

In PlatformIO this leads to compiler errors, but it works fine in Arduino IDE. I assume this is an issue, because it should work even though the names are the same.

This is not easily solvable. I think PlatformIO’s order of include folders is different to the Arduino IDE, where the Arduino core comes last, the libraries first. Meaning that if a library does a #include <timer.h> and the library’s folder has timer.h and the Arduino core has a timer.h, it will pick the libary’s one in the Arduino IDE, but the Arduino core’s file in PlatformIO. You can confirm that with the project task ‘Advanced → Verbose Build’ and compare the -I flag order to what the Arduino IDE does (when verbose build is checked on in the settings).

The quick way to make it work would be to fork the library on github, rename the file to something unique and its references to it, and then reference the git link in lib_deps instead of the old library.

Please open an issue in Issues · platformio/platformio-core · GitHub.

The include order is as you described:

arm-none-eabi-g++ -o .pio\build\nucleo_l053r8\src\main.cpp.o -c -std=gnu++14 -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -Os -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DPLATFORMIO=50101 -DSTM32L053xx -DSTM32L0xx -DARDUINO=10808 -DARDUINO_ARCH_STM32 -DARDUINO_NUCLEO_L053R8 -DBOARD_NAME=\"NUCLEO_L053R8\" -DHAL_UART_MODULE_ENABLED -DUSE_FULL_LL_DRIVER -DVARIANT_H=\"variant_NUCLEO_L053R8.h\" -D__CORTEX_SC=0 
 -Iinclude 
 -Isrc 
 -I.pio\libdeps\nucleo_l053r8\RF24Ethernet 
 -I.pio\libdeps\nucleo_l053r8\RF24Ethernet\utility 
 -I.pio\libdeps\nucleo_l053r8\RF24Mesh
 -I.pio\libdeps\nucleo_l053r8\RF24Network
 -I.pio\libdeps\nucleo_l053r8\RF24
 -I.pio\libdeps\nucleo_l053r8\RF24\utility
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\libraries\SPI\src
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\cores\arduino\avr
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32\LL
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32\usb
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32\OpenAMP
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32\usb\hid
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32\usb\cdc
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32L0xx_HAL_Driver\Inc
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32L0xx_HAL_Driver\Src
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\STM32L0xx
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Middlewares\ST\STM32_USB_Device_Library\Core\Inc
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Middlewares\ST\STM32_USB_Device_Library\Core\Src
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Middlewares\OpenAMP
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Middlewares\OpenAMP\open-amp\lib\include
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Middlewares\OpenAMP\libmetal\lib\include
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Middlewares\OpenAMP\virtual_driver
 -IC:\Users\Tony\.platformio\packages\framework-cmsis\CMSIS\Core\Include
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32L0xx\Include
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\gcc
 -IC:\Users\Tony\.platformio\packages\framework-cmsis\CMSIS\DSP\Include
 -IC:\Users\Tony\.platformio\packages\framework-cmsis\CMSIS\DSP\PrivateInclude
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\cores\arduino
 -IC:\Users\Tony\.platformio\packages\framework-arduinoststm32\variants\STM32L0xx\L052R(6-8)T_L053R(6-8)T_L063R8T src\main.cpp

In Arduino IDE the icludes look a bit more clever, as only relevant folders of the library and core are included.

The obvious solution with renaming the library is what I did for now. However, I think there should be a more permanent solution

1 Like