cancel
Showing results for 
Search instead for 
Did you mean: 

Couldn't compile Stm32 project

ronk123
Associate II

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?

ronk123_0-1732009629708.png

ronk123_2-1732009911071.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

8 REPLIES 8
SofLit
ST Employee

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Sure, I am attaching a .zip file of the project


@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?

ronk123_2-1732009911071.png


So do those paths cover every include file in you project?

Yes, those are all the include paths in my project. I have attached a txt file which has the console output


@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...

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Pavel A.
Evangelist III

Remove everything in the lower part of the includes dialog : Include files (-include)

 


@Pavel A. wrote:

Remove everything in the lower part of the includes dialog : Include files (-include)


Ah yes - that lower section is "Include files":

AndrewNeil_2-1732181827730.png

 

@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:

https://gcc.gnu.org/onlinedocs/cpp/Invocation.html#:~:text=Add%20the%20directory%20dir%20to%20the%20list%20of%20directories%20to%20be%20searched%20for%20header%20files%20during%20preprocessing.%20See%20Search%20Path.%20If%20dir%20begins%20with%20%E2%80%98%3D%E2%80%99%20or%20%24SYSROOT%2C%20then%20th....