2019-02-07 02:22 AM
Anyone knows how to fix undefined reference to HAL_UART_Init,HAL_UART_receive
I included all necessary files for this but somehow it doesn't find any reference
#include "stm32f4xx_hal.h"
#include "stm32f4xx_hal_conf.h"
#include "usb_device.h"
#include "usbd_comp_if.h"
#include "usbd_comp.h"
#include "usb_device.h"
#include "stm32f4xx_hal_usart.h"
#include "stm32f4xx_hal_uart.h"
#include <stm32f4xx_hal_uart.c>
#include "usbd_comp_if.h"
#include "usbd_comp.h"
#include "main.h"
#include <stm32f4xx_hal.h>
#include <stm32_hal_legacy.h>
extern HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
2020-12-16 03:18 AM
Hi,
I have the same problem!
I imported an example from the STM32Cube_FW_L0_V1.12.0 package, in this case a simple example of external interruption. So I have changed and I am trying to communicate using UART2. When I use the HAL_UART_Init () function, I'm getting the error: undefined reference to `HAL_UART_Init ' As already commented in this post by Clive1, I have already enabled the HAL_USART_MODULE_ENABLED module on stm32l0xx_hal_conf.h .
Other modules (.c) that are in the same folder of the Library are compiled but stm32l0xx_hal_uart.c is not being found, but is in the linked folder. Could someone give me a tip?
arm-none-eabi-gcc "D:/Desenvolvimento/Desenvto_software/STM32/STM32Cube_FW_L0_V1.12.0/Projects/NUCLEO-L073RZ/Examples/GPIO/GPIO_EXTI/Src/system_stm32l0xx.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DSTM32L073xx -DUSE_STM32L0XX_NUCLEO -DUSE_HAL_DRIVER -c -I../../../Inc -I../../../../../../../../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../../../../../../../../Drivers/STM32L0xx_HAL_Driver/Inc -I../../../../../../../../Drivers/BSP/STM32L0xx_Nucleo -I../../../../../../../../Drivers/CMSIS/Include -Os -ffunction-sections -Wall -fstack-usage -MMD -MP -MF"Drivers/CMSIS/system_stm32l0xx.d" -MT"Drivers/CMSIS/system_stm32l0xx.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Drivers/CMSIS/system_stm32l0xx.o"
arm-none-eabi-gcc "D:/Desenvolvimento/Desenvto_software/STM32/STM32Cube_FW_L0_V1.12.0/Drivers/BSP/STM32L0xx_Nucleo/stm32l0xx_nucleo.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DSTM32L073xx -DUSE_STM32L0XX_NUCLEO -DUSE_HAL_DRIVER -c -I../../../Inc -I../../../../../../../../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../../../../../../../../Drivers/STM32L0xx_HAL_Driver/Inc -I../../../../../../../../Drivers/BSP/STM32L0xx_Nucleo -I../../../../../../../../Drivers/CMSIS/Include -Os -ffunction-sections -Wall -fstack-usage -MMD -MP -MF"Drivers/BSP/STM32L0xx_Nucleo/stm32l0xx_nucleo.d" -MT"Drivers/BSP/STM32L0xx_Nucleo/stm32l0xx_nucleo.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Drivers/BSP/STM32L0xx_Nucleo/stm32l0xx_nucleo.o"
arm-none-eabi-gcc -o "STM32L073RZ_NUCLEO.elf" @"objects.list" -mcpu=cortex-m0plus -T"../STM32L073RZTx_FLASH.ld" --specs=nosys.specs -Wl,-Map="STM32L073RZ_NUCLEO_GPIO_EXTI.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
Example/User/main.o: In function `MX_USART2_UART_Init':
D:/Desenvolvimento/Desenvto_software/STM32/STM32Cube_FW_L0_V1.12.0/Projects/NUCLEO-L073RZ/Examples/GPIO/GPIO_EXTI/Src/main.c:168: undefined reference to `HAL_UART_Init'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:60: STM32L073RZ_NUCLEO.elf] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
21:59:32 Build Failed. 2 errors, 0 warnings. (took 6s.571ms)
2021-02-15 05:21 PM
you right, I have same problem.
I use STM32CubeIDE 1.5.1 and HAL Library. If I create project and generate code with "Copy only necessary library files" option, it works well.
But generate with "Add necessary library files as reference in the toolchain project configuration file" option, the error has occurred.
I put the mouse cursor with Error function name (HAL_GPIO_WritePin, HAL_GPIO_Init, HAL_Init... and so on) and press function key 'F3', then
IDE show me the library header file, and press F3 one more, then IDE not show the source code file. I confirm path of library files, and linking status, but I didn't see anything strange. I hope this problem is resolved.