2024-11-19 02:01 AM - last edited on 2024-11-19 02:14 AM by SofLit
I am trying to compile a STM32 project with my own code structure. I have not changed the structure created by the IDE when creating the project and have added my .c and .h files in the Src and Inc folders in Core directory. But I am getting an error where the compiler is not able to find the include paths. I am attaching the error and screenshots for your reference. I have added the include paths in project settings. Is there something that I am missing?
Solved! Go to Solution.
2024-11-19 02:48 AM - edited 2024-11-19 02:59 AM
Hello,
I don't know how did you land on this error and why you modified the include paths as there is no new path generated from CubeMx.
I've regenerated your project based on your ioc file and added uart.c file to the project, did a litte modification in main and it's compiling fine. (attached).
Removed Sys_init.c from the compilation as I don't think it will be usable. system clock is already generated automatically in main.c
Hope it helps.
2024-11-19 02:16 AM
Hello @ronk123 and welcome to the community,
It's an issue related to the path. Is that possible to share your project? if you don't want to share it in public send it in private.
Thank you.
2024-11-19 02:18 AM
2024-11-19 02:22 AM
@ronk123 wrote:But I am getting an error where the compiler is not able to find the include paths.
What error, exactly, are you getting?
Please copy the full build output from the 'Console' window, and post here as text.
@ronk123 wrote:I have added the include paths in project settings. Is there something that I am missing?
So do those paths cover every include file in you project?
2024-11-19 02:23 AM
Yes, those are all the include paths in my project. I have attached a txt file which has the console output
2024-11-19 02:35 AM
@ronk123 wrote:Yes, those are all the include paths in my project. I have attached a txt file which has the console output
Thanks - so these are the actual errors:
<command-line>: fatal error: ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy: No such file or directory compilation terminated. <command-line>: fatal error: ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy: No such file or directory compilation terminated. <command-line>: fatal error: ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy: No such file or directory compilation terminated. <command-line>: fatal error: ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy: No such file or directory compilation terminated. make: *** [Drivers/STM32F4xx_HAL_Driver/Src/subdir.mk:64: Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o] Error 1 make: *** Waiting for unfinished jobs.... <command-line>: fatal error: ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy: No such file or directory compilation terminated. make: *** [Drivers/STM32F4xx_HAL_Driver/Src/subdir.mk:64: Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o] Error 1 <command-line>: fatal error: ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy: No such file or directory compilation terminated. <command-line>: fatal error: ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy: No such file or directory compilation terminated. <command-line>: fatal error: ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy: No such file or directory compilation terminated.
They are, in fact, all the same error - they all refer to just one folder, ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy
Note that this is specified as a relative path.
The trouble with relative paths is that they only work when you start from the right place...
2024-11-19 02:48 AM - edited 2024-11-19 02:59 AM
Hello,
I don't know how did you land on this error and why you modified the include paths as there is no new path generated from CubeMx.
I've regenerated your project based on your ioc file and added uart.c file to the project, did a litte modification in main and it's compiling fine. (attached).
Removed Sys_init.c from the compilation as I don't think it will be usable. system clock is already generated automatically in main.c
Hope it helps.
2024-11-19 01:22 PM
Remove everything in the lower part of the includes dialog : Include files (-include).
2024-11-21 01:36 AM - edited 2024-11-21 01:37 AM
@Pavel A. wrote:Remove everything in the lower part of the includes dialog : Include files (-include).
Ah yes - that lower section is "Include files":
@ronk123 but the entries you have specified there are not files - they are paths!
Here is the documentation of what -include (ie, that part of the dialog) does:
https://gcc.gnu.org/onlinedocs/cpp/Invocation.html#:~:text=Process%20file%20as,chain%20as%20normal
And this is what -I (the Include Paths section) does: