LDF doesn't see header file in installed library

I want to use the FatFS library in my project. I installed it, by adding it to the lib_deps in the configuration file. It installed successfully (afaik).

Upon building it throws errors like: inc/main.h:56:10: fatal error: ff_gen_drv.h: No such file or directory

Why doesn’t it find the header file? It is referenced from my projects header file (main.h). And the file certainly is in the <PIO-project-root>/.piolibdeps/FatFs_ID1805/src/ folder.

I tried changing lib_ldf_mode to all possible values - still doesn’t help. What should I try next?

My platformio.ini file:

[platformio]
env_default = disco_f746ng
build_dir = pio_builds
include_dir = inc

[env:disco_f746ng]
platform = ststm32
board = disco_f746ng
framework = stm32cube
lib_extra_dirs = 
    /home/jure/Projects/ARMdev_stuff/STM32Cube_FW_F7_V1.11.0/Drivers/BSP
upload_protocol = stlink
lib_deps =
    FatFS

And project structure:

1 Like

One workaround to make LDF see the missing header file is adding the path manually via build flags.
I added this line to my platformio.ini:

build_flags = 
    -I/home/jure/Projects/ARMdev_stuff/Examples/FatFS_uSD_example/.piolibdeps/FatFs_ID1805/src

Then it found the file, but still didn’t compile.

QUESTION 1: Shouldn’t LDF automatically find files, since I installed the library “the official” way via Library Manager? Doesn’t it automatically look in the library’s src/ folder? Is the library.json problematic in this case? What is the best thing to do in this case (my workaround doesn’t seem like the prettiest/permanent solution)

Next problem I noticed was that IntelliSense could not open main.h (or any other file that was inside my projects inc/ folder). That’s why I added also my projects include folder to platformio.ini manually:

build_flags = 
    -I/home/jure/Projects/ARMdev_stuff/Examples/FatFS_uSD_example/inc
    -I/home/jure/Projects/ARMdev_stuff/Examples/FatFS_uSD_example/.piolibdeps/FatFs_ID1805/src

Then the IntelliSense issue was resolved, but I still couldn’t build the project successfully.
QUESTION 2: Since the beginning I had the include_dir = inc option added to my configuration file. Shouldn’t this take care of IntelliSense paths also? Why do I have to add this manually?

If I try to build the project at this point, I get lots of errors of this kind:
.piolibdeps/FatFs_ID1805/src/ff_gen_drv.h:83:3: error: unknown type name 'uint8_t'

Any idea how should I approach this problem?

In the repository I don’t see the ff_gen_drv.h and its included file include the relevant header file stdint.h for uint8_t. integer.h imports a bunch / delcares a bunch of Windows-style integer types. A #include <stdint.h> at the start of gg_gen_drv.h should fix that.

For the other issue: I experienced this myself sometimes but never bothered to know why. Now that we have a concrete case I’d also like to know why it does not auto-include (-I) the src folder.

But the file ff_gen_drv.h is in the repository:

And adding #include <stdint.h> indeed does solve the problem.

There’s still one problem left:

In file included from src/sd_diskio.c:47:0:
.piolibdeps/FatFs_ID1805/src/ff_gen_drv.h:88:3: error: unknown type name '__IO'

This seems to be somehow related to CMSIS headers, if I try to include the file where the __IO is defined manually (core_cm7.h from cube_root/Drivers/CMSIS/Include/) i get tons of errors like:

In file included from src/sd_diskio.c:47:0:
.piolibdeps/FatFs_ID1805/src/ff_gen_drv.h:88:3: error: unknown type name '__IO'

I don’t see an end to this >.< Since I mentioned several problem, should I open some issues here in PIO Community or maybe Git hub? Where exactly?

You read my sentence wrong / I didn’t write it carefully enough: I meant I did that these files and its children include stdint.h, I did indeed see ff_gen_drv.h file.

For me __IO leads to cmsis/TARGET_CORTEX_M/core_cm4.h with

#define     __IO    volatile             /*!< Defines 'read / write' permissions */

The file should be included by #include <cmsis.h> (should go down the rabbit hole to core_cm4.h, so try this maybe.

I’ll investigate the library later, but if it’s a library issue and it doesn’t compile on pretty much all platforms, a issue in the library’s github should be filed.

1 Like

Aah my mistake, I copied the wrong error message. After I include the core_cm7.h (because I’m working on STM32F746 discovery board, I’m pretty sure thats the right one) it gives me bunch of errors like this one:

/home/jure/.platformio/packages/framework-stm32cube/f7/Drivers/CMSIS/Include/core_cm7.h:1834:37: error: unknown type name 'IRQn_Type'; did you mean 'ITM_Type'?
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
^~~~~~~~~
ITM_Type

After you check it, please let me know if I should fill the git issue or link yours if you will do it - if that is fine with you?
Thanks alot for helping out!

Tried including cmsis.h (all variants) -> still throws ton of errors…

BTW: I didn’t actually find cmsis.h library but rather cmsis_gcc.h, cmsis_armcc.h and cmsis_armcc_V6.h

Did you get anywhere ? My first attempt with platformio and I have installed the Blinky library to project .piolibdeps and #inlcude <Blink.h> doesn’t work. I tried rebuilding the intellisense stuff. Frustrating.

This doesn’t seem to be directly related to the original problem in the thread; Please open a new thread with the full details (code, platformio.ini)

LDF doesnt see header in installed library? Seems spot on. But OK, I shall create a new topic later.