链接器找不到 crti.o 和其他目标文件

linker can't find crti.o and other object files

我正在为一个小型项目使用 this Makefile,尽管我在 /usr/lib/x86_64-linux-gnu 中有 crti.ocrtbegin.ocrt0.o,而且我在 LIBRARY_PATHLD_LIBRARY_PATH 中都有该目录,我在 运行 make:

时仍然收到以下错误
[LD]    balloons-Parafoil.elf
/afs/.ir.stanford.edu/users/e/r/ericmark/Development/balloons-
Parafoil/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-
none-eabi/bin/ld: cannot find crti.o: No such file or directory
/afs/.ir.stanford.edu/users/e/r/ericmark/Development/balloons-
Parafoil/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-
none-eabi/bin/ld: cannot find crtbegin.o: No such file or directory
/afs/.ir.stanford.edu/users/e/r/ericmark/Development/balloons-
Parafoil/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-
none-eabi/bin/ld: cannot find crt0.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [balloons-Parafoil.elf] Error 1

我应该注意,这个错误发生在我试过的 Ubuntu 台机器上,但在我正在开发的 macOS 机器上没有。

C 运行-time 文件如 crti.o 是高度特定于机器的。您不能使用 /usr/lib/x86_64-linux-gnu 中的 x86-64 版本来创建 ARM 二进制文件。您需要这些文件的版本以用于您要定位的 32 位 ARM 变体。查看 the Canonical downloads page,目前的 Ubuntu 似乎不再支持 32 位 ARM,但您可以在启用相关的 Debian 存储库后安装 libc6-dev:armel。也有可能是你使用的工具链设置不正确。

此外,如果您的 ARM 工具链以裸机为目标,glibc 对您没有用,因为 glibc 假定有一个 运行ning Linux 内核可以使用。