我开始使用this video中的教程编写操作系统内核。我已经编写了Makefile,你可以在这里看到:
x86_64_asm_source_files := $(shell find src/impl/x86_64 -name *.asm) # Holds the list of all of the assembly source files.
x86_64_asm_object_files := $(patsubst src/impl/x86_64/%.asm, build/x86_64/%.o, $(x86_64_asm_source_files)) # Holds the list of all of the obj files.
# Define the command we need to run to build one of the object files from the source files:
$(x86_64_asm_object_files): build/x86_64/%.o : src/impl/x86_64/%.asm
# For compiling the assembly files:
mkdir -p $(dir $@) && \
nasm -f elf64 $(patsubst build/x86_64/%.o, src/impl/x86_64/%.asm, $@) -o $@
# Create a custom phony command:
.PHONY: build-x86_64
# Run only if any of the object files have been changed:
build-x86_64: $(x86_64_asm_object_files)
# For generating the '.iso' file:
mkdir -p dist/x86_64 && \
x86_64-elf-ld -n -o dist/x86_64/kernel.bin -T targets/x86_64/linker.ld $(x86_64_asm_object_files) && \
cp dist/x86_64/kernel.bin targets/x86_64/iso/boot/kernel.bin && \
grub-mkrescue /usr/lib/grub/i386-pc -o dist/x86_64/kernel.iso targets/x86_64/iso当我在一个停靠容器中运行make build-x86_64时,我得到了这个错误:
make: *** No rule to make target 'build-x86_64'. Stop.当我只编写make命令时,由于这个错误,似乎没有makefile:
make: *** No targets specified and no makefile found. Stop.当我在docker之外使用make命令时,我得到:
mkdir -p build/x86_64/boot/ && \
nasm -f elf64 src/impl/x86_64/boot/main.asm -o build/x86_64/boot/main.o
mkdir -p build/x86_64/boot/ && \
nasm -f elf64 src/impl/x86_64/boot/header.asm -o build/x86_64/boot/header.o
mkdir -p dist/x86_64 && \
x86_64-elf-ld -n -o dist/x86_64/kernel.bin -T targets/x86_64/linker.ld build/x86_64/boot/main.o build/x86_64/boot/header.o && \
cp dist/x86_64/kernel.bin targets/x86_64/iso/boot/kernel.bin && \
grub-mkrescue /use/lib/grub/i386-pc -o dist/x86_64/kernel.iso targets/x86_64/iso
/bin/sh: 2: x86_64-elf-ld: not found
make: *** [Makefile:16: build-x86_64] Error 127我用来构建docker本身的docker命令是:sudo docker build buildenv -t learnos-buildenv
我用来运行停靠终端的停靠命令是:sudo docker run --rm -it -v /root/env learnos-buildenv
我能做些什么来修复docker吗?或者如何在不使用docker的情况下获得x86_64-elf-ld编译器
(我的开发操作系统是Ubuntu 20.04.2.0 LTS。)
发布于 2021-06-25 02:00:36
当我在makefile中使用ld命令而不是x86_64-elf-ld命令时,一切都可以正常工作,而且我也没有使用docker编译我的项目。如果有更好的解决方案,包括从docker编译文件,请写信给我。
谢谢!
https://stackoverflow.com/questions/68117136
复制相似问题