Undefined reference to HAL_UART_Init
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 2: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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 3:00 AM
A common convention in C coding is to NEVER EVER # include *.c files, i.e. sources.
Apart from that, check where the missing function is implemented, and if the regarding source file is built with the project. In this case, supposedly stm32f4xx_hal_uart.c.
Including said source file would effectively create a second implementation, resulting in duplicate linker symbols.
You don't use C++, do you ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 3:18 AM
Including the C file is probably a desperate attempt to get the function defined :)
The unresolved reference likely occurs because HAL_UART_MODULE_ENABLED not defined:
This normally should be defined in your stm32f4xx_hal_conf.h.
It is created and updated by CubeMX. If you added the UART outside of the Cube, add also #define HAL_UART_MODULE_ENABLED in the .h
-- pa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 3:25 AM
no i use c
i removed the double implementation it still throws an error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 3:26 AM
Hi :beaming_face_with_smiling_eyes:
I defined it thanks for the hint but it still isn't defined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 3:55 AM
Look from where comes the error - compiler or linker. Undefined reference is a linker error and means that compiled function can't be found in object files. In this case it means that stm32f4xx_hal_uart.c is not compiled and linked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 4:12 AM
Post the exact error message from your toolchain, not just short excerpts.
And don't forget preceeding errors, if any.
As a general rule, always start fixing with the first compiler error. Small syntactical errors can cause a torrent of aftereffects.
Do a file search in *.c files for the HAL_UART_Init label.
One of the files should supposedly be part of your project.
If so, check for surrounding # if / # ifdef labels, that possible keep your compiler from seeing it.
Know your tools.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 6:24 AM
ST does this differently, you include one top level include file, and it then pulls the stm32f4xx_hal_conf.h where you've marked the specific modules you want to include. And then you add the .C files from the library into the project.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 6:26 AM
thanks I fixed it that way.
Now i got my composite device working any idea why i can't connect to USB Serial Device COM Port?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-07 6:26 AM
