裸机:在 Makefile 期间,我收到此错误“..../arm-none-eabi/bin/ld:错误:.:读取:是一个目录”

Bare-Metal : During Makefile I receive this error "..../arm-none-eabi/bin/ld: error: .: read: Is a directory"

提问人:Dustin Lim 提问时间:8/16/2023 更新时间:8/16/2023 访问量:26

问:

我正在使用 Ubuntu 22.04 进行一些裸机编程。 我有 3 个文件要编译和链接以创建 .elf 文件名 app.elf(我使用 Makefile 来执行此操作)。 但是,我遇到了以下错误:

$ make all    
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -std=gnu11 -Wall -O0 -c -o main.o main.c
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -std=gnu11 -Wall -O0 -c -o startup.o startup.c
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -std=gnu11 -Wall -O0 -c -o gpio.o gpio.c
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -nostdlib -T stm32_ls.ld -Wl,-Map=app.map -o app.elf main.o startup.o gpio.o
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: error: .: read: Is a directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: app.elf] Error 1

这是我的 Makefile 脚本:

CC=/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc
MACH=cortex-m3
CFLAGS=-mcpu=$(MACH) -mthumb -std=gnu11 -Wall -O0
LDFLAGS=-nostdlib -T stm32_ls.ld -Wl,-Map=app.map

all: app.elf

app.elf: main.o startup.o gpio.o
    $(CC) $(LDFLAGS) -o $@ $^

main.o: main.c
    $(CC) $(CFLAGS) -c -o $@ $^

startup.o: startup.c
    $(CC) $(CFLAGS) -c -o $@ $^

gpio.o: gpio.c
    $(CC) $(CFLAGS) -c -o $@ $^

clean:
    rm -f *.o *.elf *.map

我尝试重新安装工具链并确保所有文件权限都处于可执行状态。

我认为这个错误更多地是在 linux 方面而不是工具链上,但我可能是错的,因为我仍然是这两个领域的初学者。

如果有人知道如何解决这个问题,请回复。谢谢!

makefile 链接器错误 ubuntu-22.04 裸机 arm-none-eabi-gcc

评论

1赞 MadScientist 8/16/2023
此错误看起来像是链接器已获得要尝试链接的文件,这当然不起作用,因为它是目录,而不是文件。我没有立即在链接器命令行上看到错误,这让我相信这可能是您正在使用的链接器脚本中的错误.: read: Is a directory..stm32_ls.ld
0赞 Dustin Lim 8/16/2023
哦,谢谢,它现在可以工作了。这个点本来是用来表示“.= ALIGN(4)“,但似乎我输入了错误的语法,谢谢!

答: 暂无答案