cancel
Showing results for 
Search instead for 
Did you mean: 

CubeIDE cannot find header files after import

rcard
Associate II

This is an issue i currently have with two differents project. After importing an error free project, the IDE have issue linking included files.

When building i have "fatal error: FLASH_G0.h: No such file or directory" on the #include "foo.h" line, as if the .h weren't there.

But the file are there, and when i press F3 over the foo.h, the IDE open foo.h without any issue, proving the files are there and the IDE know where they are.

But i still have the error when building.

I tried the following things:

-refresh the project

-rebuild index & freshen all files

-remove the .h, refresh, put back the .h, refresh

-remove & import again the project.

Nothing fixed it and i'm running out of idea to try fixing the issue.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Ensure the directory of the header file is listed in your include paths for the compiler.

right click project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> MCU GCC Compiler -> Include paths

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

8 REPLIES 8
TDK
Guru

Ensure the directory of the header file is listed in your include paths for the compiler.

right click project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> MCU GCC Compiler -> Include paths

If you feel a post has answered your question, please click "Accept as Solution".
rcard
Associate II

That was my issue... I feel stupid.

Thanks you for your answer!

HNguy.25
Associate III

Sorry to bring this thread up again. If I want to add new header file to one of the Include paths, how can I update that path to display the new added header files?

Right now, I added new header files in Core/Inc (not shown in Project Explorer) but when I expand Core/Inc, the new added header files are not there.

Should be a refresh option. F5 or right click refresh or something.
If you feel a post has answered your question, please click "Accept as Solution".

Hello, thank you for your response. I did that already but nothing was updated. This was one of the thing I did: Via File Explorer at the Core/Inc, I created a file called testing.h. Then, although I refreshed the Project Explorer tab many times, there was no testing.h in the red area.

0693W00000SuPkNQAV.png

The screenshot you posted is not a file listing of a directory, it is a list of files included in the project, hence the “Included�? node above them. The file listing is farther down the screen.
This feels like a different issue than the OP.
If you feel a post has answered your question, please click "Accept as Solution".

I am sorry. I looked at a wrong direction. That is why I could not find my newly created files. Thank you very much for your response.

AMabi.1
Associate III

Hi, I'm having a similar problem. When compiling, I have errors saying that header files do not exist. The project is a simple PWM on a LED. The include paths are configured. I cleaned the project, workspace, etc and restarted everything but the errors are still there. Any idea on how to solve this problem?

Example:

.../Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c:22:10: fatal error: usbh_core.h: No such file or directory
   22 | #include "usbh_core.h"
      |          ^~~~~~~~~~~~~

usbh_core.h is in /Middlewares/ST/STM32_USB_Host_Library/Core/Inc which is a configured path (see screenshot)


_legacyfs_online_stmicro_images_0693W00000bihTCQAY.png 

P-S: F3 does work so the IDE recognises the files.