PlatformIO Community

I want to add include path

I am using vs code.
I am using stm32f103 and I am using cubemx platform.
However, the libraries of sensors mostly use the arduino platform.
I am trying to port because I want to use such a library.

The problem is that the path of header files cannot be found as the first gateway.
So I want to add the path where the libraries in other paths are.
please tell me how to do it

For reference, the terminal log is as follows:

Processing genericSTM32F103VE (platform: ststm32; board: genericSTM32F103VE; framework: stm32cube)
-------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103VE.html
PLATFORM: ST STM32 (14.0.0) > STM32F103VE (64k RAM. 512k Flash)
HARDWARE: STM32F103VET6 72MHz, 64KB RAM, 512KB Flash
DEBUG: Current (jlink) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
 - framework-stm32cubef1 1.8.3
 - tool-ldscripts-ststm32 0.1.0
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 28 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_adc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_adc_ex.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_can.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_cec.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_cortex.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_crc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_dac.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_dac_ex.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_dma.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_eth.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_exti.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_flash.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_flash_ex.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_gpio.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_gpio_ex.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_hcd.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_i2c.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_i2s.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_irda.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_iwdg.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_mmc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_nand.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_nor.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_pccard.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_pcd.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_pcd_ex.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_pwr.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_rcc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_rcc_ex.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_rtc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_rtc_ex.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_sd.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_smartcard.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_spi.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_sram.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_tim.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_tim_ex.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_uart.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_usart.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_hal_wwdg.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_adc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_crc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_dac.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_dma.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_exti.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_fsmc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_gpio.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_i2c.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_pwr.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_rcc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_rtc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_sdmmc.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_spi.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_tim.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_usart.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_usb.o
Compiling .pio\build\genericSTM32F103VE\FrameworkHALDriver\Src\stm32f1xx_ll_utils.o
Compiling .pio\build\genericSTM32F103VE\src\main.o
Compiling .pio\build\genericSTM32F103VE\src\stm32f1xx_hal_msp.o
Compiling .pio\build\genericSTM32F103VE\src\stm32f1xx_it.o
Compiling .pio\build\genericSTM32F103VE\src\system_stm32f1xx.o
Compiling .pio\build\genericSTM32F103VE\FrameworkCMSISDevice\gcc\startup_stm32f103xe.o
Compiling .pio\build\genericSTM32F103VE\FrameworkCMSISDevice\system_stm32f1xx.o
src\main.c:22:10: fatal error: main.h: No such file or directory

**************************************************************
* Looking for main.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:main.h"
* Web  > https://platformio.org/lib/search?query=header:main.h
*
**************************************************************

 #include "main.h"
          ^~~~~~~~
compilation terminated.
src\stm32f1xx_hal_msp.c:23:10: fatal error: main.h: No such file or directory

**************************************************************
* Looking for main.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:main.h"
* Web  > https://platformio.org/lib/search?query=header:main.h
*
**************************************************************

 #include "main.h"
          ^~~~~~~~
compilation terminated.
*** [.pio\build\genericSTM32F103VE\src\main.o] Error 1
src\stm32f1xx_it.c:22:10: fatal error: main.h: No such file or directory

**************************************************************
* Looking for main.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:main.h"
* Web  > https://platformio.org/lib/search?query=header:main.h
*
**************************************************************

 #include "main.h"
          ^~~~~~~~
compilation terminated.
*** [.pio\build\genericSTM32F103VE\src\stm32f1xx_hal_msp.o] Error 1
*** [.pio\build\genericSTM32F103VE\src\stm32f1xx_it.o] Error 1
============================================== [FAILED] Took 4.83 seconds ==============================================
The terminal process "C:\Users\ilk48\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.

This is the content of the platformio.ini I tried.

[evn]
lib_dir = 
    -I Middlewares/ST
    -I D:/00_Schaffengott/107_FireStation/02_Firmware/STM32F103_JTAG_TEST/Inc
build_flags = 

    -I D:/00_Schaffengott/107_FireStation/02_Firmware/STM32F103_JTAG_TEST/Inc
    -I D:/00_Schaffengott/107_FireStation/02_Firmware/STM32F103_JTAG_TEST/.pio/libdeps/genericSTM32F103VE/Adafruit HTU21DF Library
src_dir = D:/00_Schaffengott/107_FireStation/02_Firmware/STM32F103_JTAG_TEST/src

[env:genericSTM32F103VE]
platform = ststm32
board = genericSTM32F103VE
framework = stm32cube
build_type = debug
debug_tool = jlink
board_debug.jlink_device = STM32F103VE
upload_protocol = jlink
lib_deps = adafruit/Adafruit HTU21DF Library@^1.0.5

Thank you for your help.

lib_dir sets the path of the one folder in which libraries can be found, by default lib/ of the project folder. You are putting there multiple -I options, which is wrong. Also this option is only valid for the [platformio] section. But why change this at all?

Why change this? If D:/00_Schaffengott/107_FireStation/02_Firmware/STM32F103_JTAG_TEST/ is the project path, then that path plus src/ will already be the default src_dir.

I think you meant [env].

  1. If D:/00_Schaffengott/107_FireStation/02_Firmware/STM32F103_JTAG_TEST is your project folder, then instead of the first option, you should be using include_dir
  2. While the second line may attempt to include the headers found in that folder, none of the library files will be compiled because they are excluded from the build due to the compatibility settings lib_deps = adafruit/Adafruit HTU21DF Library@^1.0.5 is Arduino library, PIO recognizes that and excludes it. If you want to still force inclusion, use lib_compat_mode = off in the platformio.ini (docs). Then, none of those build_flags are necessary.

But, take a minute and think. If you look at the library you want to use, you will see that it in turn depends on the Adafruit_BusIO library. You will see that that in turn depends on the functions in the Arduino core (Arduino.h), the Wire (Wire.h) library for I2C transfers and the Arduino SPI library (SPI.h) for SPI transfers. You will have to re-implement all needed core functions if you want that to work, which is a lot of unnecessary work.

I’d rather suggest you copy the Adafruit_HTU21DF_Library library into your project’s lib/ folder, remove the library.properties file (so PlatformIO does not recognize it as an incompatible Arduino library anymore), remove all dependencies and start implementing the needed I2C transfer functions. The sensor library literally only needs a I2C read and write functions here to read out the sensor.

Also keep in mind that the library is written in C++, so you will have to rename main.cmain.cpp if you want to sensibly interface with a C++ library…

This error is however not related to any library. You probably forgot to copy the main.h header file into the project, or include paths are set up wrongly.

2 Likes

Thanks for your reply.
The last question was also solved with your help, and this question has been given a lot of thought as an answer.
I was approaching with the judgment that dac, dma, etc. were not implemented when using the arduino platform.
But it took me a long time to confirm that it wasn’t.
With your answer I was able to recheck the arduino platform and found the answer.
Thank you.