首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OSDev -在'docker‘中使用'make’命令时出错

OSDev -在'docker‘中使用'make’命令时出错
EN

Stack Overflow用户
提问于 2021-06-24 21:53:57
回答 1查看 54关注 0票数 0

我开始使用this video中的教程编写操作系统内核。我已经编写了Makefile,你可以在这里看到:

代码语言:javascript
复制
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时,我得到了这个错误:

代码语言:javascript
复制
make: *** No rule to make target 'build-x86_64'.  Stop.

当我只编写make命令时,由于这个错误,似乎没有makefile

代码语言:javascript
复制
make: *** No targets specified and no makefile found.  Stop.

当我在docker之外使用make命令时,我得到:

代码语言:javascript
复制
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。)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-25 02:00:36

当我在makefile中使用ld命令而不是x86_64-elf-ld命令时,一切都可以正常工作,而且我也没有使用docker编译我的项目。如果有更好的解决方案,包括从docker编译文件,请写信给我。

谢谢!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68117136

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档