简体   繁体   English

如何将标准库链接到交叉编译器?

[英]How to link standard library to a cross-compiler?

I want to build xv6 on macOS, so I installed the cross-compiler toolchain i386-elf-gcc and i386-elf-gcc from a Homebrew Tap .我想在 macOS 上构建 xv6,所以我从Homebrew Tap安装了交叉编译器工具链 i386-elf-gcc 和 i386-elf-gcc 。

The problem is i386-elf-gcc cant link standard libraries while compiling.问题是 i386-elf-gcc 在编译时无法链接标准库。 I tested on a simple c file, and got the following error.我在一个简单的 c 文件上进行了测试,并得到以下错误。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    printf("d\n");
    return 0;
}

Error:错误:

> i386-elf-gcc --sysroot=usr/includes test.c
test.c:1:10: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
          ^~~~~~~~~
compilation terminated.

to resolve, you could try adding the newlib library and cross-compile it to your architecture.要解决,您可以尝试添加 newlib 库并将其交叉编译到您的架构中。 The following link says the freeware newlib can be used as source of the stdlib to compile all by yourself.下面的链接说免费软件 newlib 可以用作 stdlib 的源来自己编译。

One problem is that the standard libraries provided with most software development tool suites arrive only in object form... 一个问题是大多数软件开发工具套件提供的标准库仅以对象形式出现......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM