ld:找不到文件:Mac 终端出现 elf_i386 错误

ld: file not found: elf_i386 error on Mac Terminal

当我在终端中 运行 命令时(使用 El Capitan)

ld -m elf_i386 -T linker.ld -o kernel kasm.o kc.o

显示以下错误:

ld: warning: option -m is obsolete and being ignored
ld: file not found: elf_i386

谁能帮我解决这个问题?

when i run a command in terminal

您正在尝试 link 直接使用 ld 某种内核。这实际上是极少数直接使用 ld 是合适的情况之一。

但是,您提供给 ld 的命令行参数假设您使用的是 GNU-ld(您可能已经从 Linux 教程中复制了它们),但您 不是 使用 GNU-ld,你使用的是 MacOS 原生 linker,它不理解这些参数。

Can anybody help me with this?

请根据 "I am trying to build XXX on MacOS, following tutorial YYY, and don't understand how to adjust this Linux command to Mac OS".

提出一个单独的问题

请注意,可能根本无法在 MacOS 上构建 XXX。特别是,ld manpage 没有提到 ELF 作为可能的输出,所以如果你的 "build XXX" 目标包括构建一个 ELF 内核,你可能需要构建一个交叉 linker(运行在 Mac OS 上的 GNU-ld linker(即托管在 Mac OS 上),但为 [=13= 生成代码] 目标。