This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

keil file not including all header file from include path

Hello,

I am working on STM32F3xx discovery board with HAL driver on keil 5.

i have included the path for my header file from option target menu, but all header files from that included folder path are not getting added.
The .c file related to that header file is being added but not the header file.

can any body help me in solving this issue or is there any alternative for that.

  • It is where, and the order in which, it searches for things, it is not a directive to include everything. You still need to explicitly #include every file you want to include.

  • I have included the header file #include "stm32f3xx_hal_usart.h" in my code. when i am using function from the header file in my code. The code is compiling but shows an error while linking as below

    compiling tim.c...
    assembling startup_stm32f303xc.s...
    compiling usart.c...
    compiling funciones.c...
    compiling system_stm32f3xx.c...
    linking...
    prueba1\prueba1.axf: Error: L6218E: Undefined symbol HAL_USART_Init (referred from usart.o).
    Not enough information to list image symbols.
    Finished: 1 information, 0 warning and 1 error messages.
    "prueba1\prueba1.axf" - 1 Error(s), 8 Warning(s).
    Target not created.
    Build Time Elapsed: 00:00:18

    If i remove function HAL_USART_Init from code then it works perfectly.

    It seems because of header file #include "stm32f3xx_hal_usart.h" not getting included in include path.

  • Can you cross check by explicitly adding the path od this header file through Options for target -> C/C++ tab ?

  • Each include file in the HAL expects a specific #define to enable inclusion.

  • So in your project's stm32f4xx_hal_conf.h

    ...
    /* ########################## Module Selection ############################## */
    /**
      * @brief This is the list of modules to be used in the HAL driver
      */
    #define HAL_MODULE_ENABLED
    #define HAL_ADC_MODULE_ENABLED
    /* #define HAL_CAN_MODULE_ENABLED */
    /* #define HAL_CRC_MODULE_ENABLED */
    /* #define HAL_CEC_MODULE_ENABLED */
    /* #define HAL_CRYP_MODULE_ENABLED */
    /* #define HAL_DAC_MODULE_ENABLED */
    /* #define HAL_DCMI_MODULE_ENABLED */
    #define HAL_DMA_MODULE_ENABLED
    /* #define HAL_DMA2D_MODULE_ENABLED */
    /* #define HAL_ETH_MODULE_ENABLED */
    #define HAL_FLASH_MODULE_ENABLED
    /* #define HAL_NAND_MODULE_ENABLED */
    /* #define HAL_NOR_MODULE_ENABLED */
    /* #define HAL_PCCARD_MODULE_ENABLED */
    /* #define HAL_SRAM_MODULE_ENABLED */
    /* #define HAL_SDRAM_MODULE_ENABLED */
    /* #define HAL_HASH_MODULE_ENABLED */
    #define HAL_GPIO_MODULE_ENABLED
    /* #define HAL_I2C_MODULE_ENABLED */
    /* #define HAL_I2S_MODULE_ENABLED */
    /* #define HAL_IWDG_MODULE_ENABLED */
    /* #define HAL_LTDC_MODULE_ENABLED */
    #define HAL_PWR_MODULE_ENABLED
    /* #define HAL_QSPI_MODULE_ENABLED    */
    #define HAL_RCC_MODULE_ENABLED
    /* #define HAL_RNG_MODULE_ENABLED */
    /* #define HAL_RTC_MODULE_ENABLED */
    /* #define HAL_SAI_MODULE_ENABLED */
    /* #define HAL_SD_MODULE_ENABLED */
    #define HAL_SPI_MODULE_ENABLED
    /* #define HAL_TIM_MODULE_ENABLED */
    #define HAL_UART_MODULE_ENABLED
    #define HAL_USART_MODULE_ENABLED
    /* #define HAL_IRDA_MODULE_ENABLED */
    /* #define HAL_SMARTCARD_MODULE_ENABLED */
    /* #define HAL_WWDG_MODULE_ENABLED */
     #define HAL_CORTEX_MODULE_ENABLED
    /* #define HAL_PCD_MODULE_ENABLED */
    /* #define HAL_HCD_MODULE_ENABLED */
    #define HAL_FMPI2C_MODULE_ENABLED
    /* #define HAL_SPDIFRX_MODULE_ENABLED */
    

    If in doubt dig into the source, including the libraries, to see what the compiler is being feed.

  • Thank you Westonsupermare Pier for the solution.