本帖最后由 Afanx 于 2022-11-12 17:32 编辑
测试demo来自:《AN_N32G45x_N32G4FR_N32WB452_N32G43x_N32L43x_N32L40x_GCC开发环境应用笔记_V3.0》
搭建GCC开发环境时,修改makefile文件,把算法库添加进来,但编译失败了。不添加lib,编译可以通过,功能也正常。有大佬实现过在在GCC添加lib吗,求帮忙看看
makefile 部分代码:######################################
# Algo libs
######################################
USELIB = 1
######################################
# Lib files
######################################
ifeq ($(USELIB), 1)
SRC_LIB_DIR += ../../../../../../firmware/$(TARGET_PLATFORM)_algo_lib/lib
INC_LIB_DIR += ../../../../../../firmware/$(TARGET_PLATFORM)_algo_lib/inc
LIB_SOURCES = $(foreach DIR3, $(SRC_LIB_DIR), $(wildcard $(DIR3)/*.lib))
LIB_SOURCES_L = $(addprefix -L,$(LIB_SOURCES))
C_LIBS = $(LIB_SOURCES_L)
LIB_INCS = $(foreach DIR4, $(INC_LIB_DIR), $(wildcard $(DIR4)/*.h))
LIB_INCS_PATH = $(sort $(dir $(LIB_INCS)))
LIB_INCS_PATH_I = $(addprefix -I,$(LIB_INCS_PATH))
C_INCLUDES += $(LIB_INCS_PATH_I)
endif
测试n32g45x_algo_common.lib中的函数SetZero_U8()uint32_t SetZero_U8(uint8_t *dst, uint32_t byteLen);
main.c部分代码:
#include "n32g45x_algo_common.h"
uint8_t dat[8];
int main(void)
{
/*SystemInit() function has been called by startup file startup_n32g45x.s*/
LedInit(GPIOA, GPIO_PIN_8);
for (int i = 0; i < 8; i++)
{
dat[i] = i;
}
SetZero_U8(dat,6);
while (1)
{
LedBlink(GPIOA, GPIO_PIN_8);
systick_delay_ms(100);
}
}
编译后报错信息:
d:/gcc-arm/gnu arm embedded toolchain/10 2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: build/main.o: in function `main':
E:\Desktop\Nationstech.N32G45x_Library.2.0.0\projects\n32g45x_EVAL\examples\GPIO\LedBlink\GCC/../src/main.c:174: undefined reference to `SetZero_U8'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:143: build/output.elf] Error 1
提示未定义SetZero_U8函数,是我使用方式不对吗?lib文件在makefile中都有引用了,路径检查了也没问题。
|