(.text+0x168): undefined reference to `uart0_init'

本文详细介绍了如何在Makefile中正确编译serial.c文件中的uart0_init函数,解决未生成.o文件的问题,提供了解决方案及步骤。

修改Makefile

uart0_init在serial.c文件,但是Makefile中没有编译成为.o文件,修改之后问题解决

w@w-virtual-machine:~/桌面/cmk/Main/build$ make [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main /opt/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/bin/../lib/gcc/loongarch64-linux-gnu/8.3.0/../../../../loongarch64-linux-gnu/bin/ld: CMakeFiles/main.dir/main.cpp.o: in function `main': main.cpp:(.text+0x10): undefined reference to `TM1650_Init()' /opt/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/bin/../lib/gcc/loongarch64-linux-gnu/8.3.0/../../../../loongarch64-linux-gnu/bin/ld: main.cpp:(.text+0x14): undefined reference to `Display_Init()' /opt/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/bin/../lib/gcc/loongarch64-linux-gnu/8.3.0/../../../../loongarch64-linux-gnu/bin/ld: main.cpp:(.text+0x1c): undefined reference to `Display_Change_Brightness(unsigned char)' /opt/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/bin/../lib/gcc/loongarch64-linux-gnu/8.3.0/../../../../loongarch64-linux-gnu/bin/ld: main.cpp:(.text+0x60): undefined reference to `uart_init(char const*, int)' /opt/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/bin/../lib/gcc/loongarch64-linux-gnu/8.3.0/../../../../loongarch64-linux-gnu/bin/ld: main.cpp:(.text+0xfc): undefined reference to `Show_Num(unsigned short, unsigned char)' /opt/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/bin/../lib/gcc/loongarch64-linux-gnu/8.3.0/../../../../loongarch64-linux-gnu/bin/ld: main.cpp:(.text+0x118): undefined reference to `uart_send_time_hex(int, rtc_time*)' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/main.dir/build.make:100:main] 错误 1 make[1]: *** [CMakeFiles/Makefile2:87:CMakeFiles/main.dir/all] 错误 2 make: *** [Makefile:91:all] 错误 2
07-23
在使用STM32CubeIDE进行编译时,出现以下错误: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/gpio.c:51:(.text.MX_GPIO_Init+0x72): undefined reference to `HAL_GPIO_WritePin' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/gpio.c:58:(.text.MX_GPIO_Init+0x98): undefined reference to `HAL_GPIO_Init' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/main.o: in function `main': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:85:(.text.main+0x4): undefined reference to `HAL_Init' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:115:(.text.main+0x20): undefined reference to `HAL_UART_Receive_IT' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:126:(.text.main+0x3e): undefined reference to `HAL_UART_Transmit_IT' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/main.o: in function `SystemClock_Config': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:162:(.text.SystemClock_Config+0x66): undefined reference to `HAL_RCC_OscConfig' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:174:(.text.SystemClock_Config+0x92): undefined reference to `HAL_RCC_ClockConfig' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:180:(.text.SystemClock_Config+0xae): undefined reference to `HAL_RCCEx_PeriphCLKConfig' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/stm32f0xx_it.o: in function `SysTick_Handler': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/stm32f0xx_it.c:130:(.text.SysTick_Handler+0x4): undefined reference to `HAL_IncTick' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/stm32f0xx_it.o: in function `USART1_IRQHandler': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/stm32f0xx_it.c:151:(.text.USART1_IRQHandler+0x8): undefined reference to `HAL_UART_IRQHandler' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/stm32f0xx_it.o: in function `USART2_IRQHandler': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/stm32f0xx_it.c:165:(.text.USART2_IRQHandler+0x8): undefined reference to `HAL_UART_IRQHandler' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/usart.o: in function `MX_USART1_UART_Init': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/usart.c:45:(.text.MX_USART1_UART_Init+0x46): undefined reference to `HAL_UART_Init' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/usart.o: in function `MX_USART2_UART_Init': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/usart.c:66:(.text.MX_USART2_UART_Init+0x46): undefined reference to `HAL_UART_Init' collect2.exe: error: ld returned 1 exit status make: *** [makefile:63: usart2comm.elf] Error 1 "make -j12 all" terminated with exit code 2. Build might be incomplete. 15:08:20 Build Failed. 14 errors, 0 warnings. (took 5s.624ms)
07-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值