linker - STM32 CubeIDE code fails to link: undefined reference to `HAL_RTC_GetTime` - Stack Overflow

I had some problems linking some company code and the supplied STM32 CubeIDE code together, the linker

I had some problems linking some company code and the supplied STM32 CubeIDE code together, the linker was complaining about undefined references to ST's HAL_RTC and HAL_RTCEx code:

ld: home/.../foobar.o: in function `foobar_myFunc': /home/.../foobar.c: undefined reference to `HAL_RTCEx_BKUPWrite'
ld: /home/.../foobar.o: in function `rtcHal_getUnixTime': /home/.../foobar.c:902: undefined reference to `HAL_RTC_GetTime'
ld: /home/.../foobar.c:921: undefined reference to `HAL_RTC_GetDate'
ld: /home/.../foobar.c:929: undefined reference to `HAL_RTC_GetTime'
collect2: error: ld returned 1 exit status

I had some problems linking some company code and the supplied STM32 CubeIDE code together, the linker was complaining about undefined references to ST's HAL_RTC and HAL_RTCEx code:

ld: home/.../foobar.o: in function `foobar_myFunc': /home/.../foobar.c: undefined reference to `HAL_RTCEx_BKUPWrite'
ld: /home/.../foobar.o: in function `rtcHal_getUnixTime': /home/.../foobar.c:902: undefined reference to `HAL_RTC_GetTime'
ld: /home/.../foobar.c:921: undefined reference to `HAL_RTC_GetDate'
ld: /home/.../foobar.c:929: undefined reference to `HAL_RTC_GetTime'
collect2: error: ld returned 1 exit status
Share Improve this question edited Mar 6 at 0:36 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked Mar 4 at 13:35 beyarkaybeyarkay 1,0891 gold badge8 silver badges27 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The solution was simply that the entire file stm32f7xx_hal_rtc_ex.c and stm32f7xx_hal_rtc.c are wrapped in an #ifdef HAL_RTC_MODULE_ENABLED, and I hadn't defined that macro.

If you uncomment the HAL_RTC_MODULE_ENABLED line in stm32f7xx_hal_conf.h, the functions in the file will actually be compiled and you'll be able to link the code.

 /* #define HAL_QSPI_MODULE_ENABLED   */
 /* #define HAL_RNG_MODULE_ENABLED   */
+#define HAL_RTC_MODULE_ENABLED
-/* #define HAL_RTC_MODULE_ENABLED */
 /* #define HAL_SAI_MODULE_ENABLED   */
 /* #define HAL_SD_MODULE_ENABLED   */

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745040800a4607794.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信