arm-none-eabi-gcc -o "SENSOR_CB.elf" @"objects.list" -mcpu=cortex-m3 -T"C:\Users\WangBingqian\Desktop\SC10L151Cube\trunk\NO_FOTA_VERSION\STM32L151CBTXA_FLASH.ld" --specs=nosys.specs -Wl,-Map="SENSOR_CB.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group Core/Src/rs485.o: In function `get_sample_data_max_min_value': rs485.c:(.text.get_sample_data_max_min_value+0x0): multiple definition of `get_sample_data_max_min_value' Core/Src/lora_wan.o:lora_wan.c:(.text.get_sample_data_max_min_value+0x0): first defined here Core/Src/rs485.o: In function `computeMvScale': rs485.c:(.text.computeMvScale+0x0): multiple definition of `computeMvScale' Core/Src/lora_wan.o:lora_wan.c:(.text.computeMvScale+0x0): first defined here Core/Src/rs485.o: In function `computeMvScale_f': rs485.c:(.text.computeMvScale_f+0x0): multiple definition of `computeMvScale_f' Core/Src/lora_wan.o:lora_wan.c:(.text.computeMvScale_f+0x0): first defined here Core/Src/rs485.o: In function `generate_frag_data': rs485.c:(.text.generate_frag_data+0x0): multiple definition of `generate_frag_data' Core/Src/lora_wan.o:lora_wan.c:(.text.generate_frag_data+0x0): first defined here Core/Src/rs485.o:(.bss.frag_num+0x0): multiple definition of `frag_num' Core/Src/lora_wan.o:(.bss.frag_num+0x0): first defined here collect2.exe: error: ld returned 1 exit status make: *** [makefile:50: SENSOR_CB.elf] Error 1 "make -j4 all" terminated with exit code 2. Build might be incomplete.是什么错误
时间: 2024-04-06 12:35:10 浏览: 14
这是一个编译错误,具体原因是因为链接器发现了多个重名的函数或变量,导致链接失败。具体来说,错误信息中显示了多个符号(如函数和变量)的多重定义(multiple definition)错误,其中一个定义在 "rs485.c" 文件中,另一个定义在 "lora_wan.c" 文件中。此外,链接器还指出了一些符号的定义在多个文件中,这也可能会导致链接失败。
要解决这个问题,你需要检查代码中是否存在重名的函数或变量,如果有的话,需要给它们改名或者将其中一个重名的函数或变量删除。另外,你还需要确保每个符号只有一个定义,可以通过使用头文件等方式来确保变量或函数只被定义一次。
相关问题
试设计一个makefile来获取.elf的链接脚本
好的,以下是一个示例的makefile代码,用于获取.elf的链接脚本:
```
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld
CFLAGS = -Wall -c -fno-common -mcpu=cortex-m3 -mthumb
LDFLAGS = -T linker_script.ld -nostdlib
OBJS = main.o foo.o bar.o
all: program.elf
program.elf: $(OBJS)
$(LD) $(LDFLAGS) $(OBJS) -o $@
%.o: %.c
$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f $(OBJS) program.elf
```
这个makefile使用arm-none-eabi-gcc编译器和链接器,指定了链接脚本为linker_script.ld,以及一些编译和链接的参数。makefile会自动编译每个.c文件并生成对应的.o目标文件,最终链接成program.elf可执行文件。如果需要清理生成的目标文件和可执行文件,可以执行"make clean"命令。
.\Objects\Project.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _sys_exit was referenced
这个错误提示是由ARM编译器产生的。它表示在编译的过程中发现了一个问题:你请求使用无半主机模式,但是某个地方引用了_sys_exit,这会导致链接错误。
解决这个问题的方法是在编译选项中关闭使用无半主机模式的选项。具体来说,你需要在编译命令中加入一个参数:“--specs=rdimon.specs”来使用半主机模式。这样就可以避免上述错误了。
例如,在使用ARM GCC编译器时,你可以这样设置编译选项:
```
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -specs=rdimon.specs main.c -o main.elf
```
这样就可以正确编译你的代码了。