ARM 的 Clang 交叉编译

标签 c arm clang llvm

我正在尝试使用 arm-none-eabi(这是 Debian 的软件包)为 ARM(特别是 Cortex-M3)编译一个包含 stdint.h 的文件标题。命令是:

clang -I/usr/lib/gcc/arm-none-eabi/4.8/include \
    -target arm-none-eabi cfile.c -o cfile.o

(-mcpu-mfpu-mfloat-abi 为简单起见省略)

返回错误:

In file included from cfile.c:1:
In file included from ./cfile.h:4:
In file included from /usr/lib/gcc/arm-none-eabi/4.8/include/stdint.h:9:
In file included from /usr/lib/llvm-3.5/bin/../lib/clang/3.5.0/include/stdint.h:61:
In file included from /usr/include/stdint.h:25:
/usr/include/features.h:374:12: fatal error: 'sys/cdefs.h' file not found
#  include <sys/cdefs.h>
           ^
1 error generated.

我一直在关注 this guide .

我的版本:

$ clang --version
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (4.8.4-1+11-1) 4.8.4 20141219 (release)

关于如何解决这个问题有什么想法吗?

P.S.:不是 this question 的副本.

最佳答案

要解决此问题,您必须安装 g++-multilib
g++-multilib - GNU C++ 编译器,一个相当可移植的 C++ 优化编译器。 它将安装所需的 header 。

作为 sysroot 选项的答案(来自评论部分): 你是绝对正确的 sysroot 应该与从 zips 安装的交叉编译器一起使用。从您尝试使用哪个编译器的问题中不清楚。

关于ARM 的 Clang 交叉编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35295502/

相关文章:

c - Strcpy 在同一上下文中第二次使用时崩溃了

c - C 函数调用的 ARM 汇编函数中的寄存器使用情况

使用 OpenOCD 的 ARM LPC1768 的 Eclipse GDB "init"和 "run"设置?

c++ - Clang 静态链接 libc++

c++ - 声明和定义之间对 const 限定符的使用不一致

c - 如何将char数组的内容读写到文件中?

c - 在 C 中获取函数指针的这些方法有区别吗?

c - 静态链接中目标文件和库的排序

ios - iOS 上编译成功但执行汇编 MRC 指令失败?

c++ - 是否可以执行差异链接?