cancel
Showing results for 
Search instead for 
Did you mean: 

Header file not found - "No such file or directory" - but it exists!

SElli.11
Associate III

Hi,

Having successfully installed SW4STM32 I recently tried to build the example project detailed on the RIP Tutorial web page entitled "First time setup with blink LED example using SW4STM32 and HAL library". This "threw up" four errors. The first was classed as a fatal error whilst the other three errors involved "make" which I believe are due to the first error.

Within the IDE, on the "Problems" tab, the first error is listed as follows.

Description: fatal error: usbh_conf.h: No such file or directory
Resource: usbh_conf.h
Path: /STM32F4_Discovery_Blinky/Middlewares/ST/STM32_USB_Host_Library/Core/Inc line 28 C/C++ Problem

Within the ".../Inc/" directory is a further subdirectory called "usbh_core.h" within which is the "offending" (non-existent?!) usbh_conf.h This header file is clearly listed on both the Project Explorer and Outline tabs within the IDE. Opening this file shows the following. (How could this be done if the file did not exist ?!)

 

/**
******************************************************************************
* @file usbh_core.h
* @author MCD Application Team
* @brief Header file for usbh_core.c
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive ----------------------------------------------*/
#ifndef __USBH_CORE_H
#define __USBH_CORE_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "usbh_conf.h"
#include "usbh_def.h"
#include "usbh_ioreq.h"
#include "usbh_pipes.h"
#include "usbh_ctlreq.h"

 

It can be clearly seen that, with the first "#include", the file includes itself. The IDE flags this line (line 28 within usbh_conf.h) as the source of the error as the line is prepended with an error indicator in the form of a red square containing a yellow cross. Is this instance of the file including itself some form of overlooked/unintended file-level recursion ? Given the compiler directives that immediately precede this line, this would seem to be the case. I am at a loss at this point.

Stuart

 

6 REPLIES 6

You're posting in the public community.

If you want to contact ST direct, you need to open a Case with the Support Centre:

AndrewNeil_0-1727687007394.png

 

Please see the posting tips for how to properly post source code:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

 


@SElli.11 wrote:

Within the IDE, on the "Problems" tab, the first error is listed as follows.


The 'Problems' tab re-orders messages, so it's not useful for determining which is the "first" error.

Use the 'Console' view instead:

https://community.st.com/t5/stm32cubeide-mcus/stmcubeide-generating-errors-in-the-driver-files-on-creation-of/m-p/97912/highlight/true#M2765

The 'Console' view also gives extra indications of what & where, exactly, it's complaining about.

 


@SElli.11 wrote:

Is this instance of the file including itself some form of overlooked/unintended file-level recursion ?


The header files all have so-called 'Include Guards'; eg,

 

/* Define to prevent recursive ----------------------------------------------*/
#ifndef __USBH_CORE_H
#define __USBH_CORE_H

 

So, no - this would not be a problem.

 


@SElli.11 wrote:

This header file is clearly listed on both the Project Explorer and Outline tabs within the IDE. Opening this file shows the following. (How could this be done if the file did not exist ?!)


The IDE's editor knows where to find it, but the Compiler - which is what actually builds your code - doesn't

The Compiler uses the 'Include Paths' setting to find #include-d files

So check you 'Include Paths' - they need to list the place where this header exists.

 

PS:

See: https://community.st.com/t5/stm32cubeide-mcus/files-not-being-recognized-if-inside-folder/m-p/716138/highlight/true#M30405

 


@SElli.11 wrote:

the RIP Tutorial web page


You mean this: https://riptutorial.com/ ?

That's a 3rd-party website - nothing to do with ST

FBL
ST Employee

Hi @SElli.11 

usbh_conf.h is configuration file among header files. Maybe you didn't rename the template file and keep it as it is usbh_conf_template.h 

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.

Goo evening FBL,

Thank you for your reply

"Maybe you didn't rename the template file and keep it as it is usbh_conf_template.h "

 

As I state in the first two lines of my original posting :-

"...I recently tried to build the example project detailed on the RIP Tutorial web page entitled "First time setup with blink LED example using SW4STM32 and HAL library"."

To be clear, the code that I showed in my original posting here was copied and pasted directly from that web page.

An examination of that source code will show that there wasn't/isn't a file called usbh_conf_template.h. Do you mean that I should rename usbh_conf.h itself to usbh_conf_template.h or that the #include usbh_conf.h within(!) the file should be changed to #include usbh_conf_template.h ? This template name may not be recognised by the build system as it is not in the folder/file path of the original software shown on that web page.

 

From what I can see, I think this reduces to a naming conflict. I'm just not sure whether usbh_conf.h should change its name or whether the file name that is #include-d within usbh_conf.h should change its name. The only support that is available on the RIP Tutorial web page is a chatGPT bot which I seriously doubt could handle this question.

Stuart

Good evening Mr Neil,

"You mean this: https://riptutorial.com/ ?

That's a 3rd-party website - nothing to do with ST"

 

Yes, I was aware of that when I made my original posting. I merely mentioned the web page in my original posting so that should anyone offer to help they would know from where I got the source code.

 

Stuart

You may start a new project since I cannot progress in this subject without sharing your project. It seems, you are only missing the configuration file (or maybe the tutorial). You need to check the conf file should be present in your project and properly included under 'Include Paths'

 

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.