Header 在 Raspberry Pi 上使用 Clang 编译时将 stdint.h 添加到我的 C 代码时未发现错误

Header not found error when adding stdint.h to my C code when compiling with Clang on Raspberry Pi

这是我遇到的错误,none 的在线解决方案有效地解决了我遇到的问题。只需添加 #include <stdint.h> 就会破坏我的代码编译。我尝试安装 multilib,但该库似乎不支持 Ubuntu。我也尝试了一些兼容性库,但无济于事。

clang -O2 -target bpf -c hello.c -o hello.o
In file included from hello.c:2:
In file included from /usr/lib/llvm-11/lib/clang/11.0.0/include/stdint.h:52:
/usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not found
#include <bits/libc-header-start.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

参考代码。我正在尝试 运行 ARM 设备上的 uBPF 编译版本

#include <stdint.h>

static int idouble(int a)
{
    return (a * 2);
}

int bpf_prog(void *ctx)
{
    int a = 1;
    a = idouble(a);
    return (a);
}

这个问题是基于关于如何使用 uBPF 设置用户输入的 Klyr's 教程。

我实际上能够解决我的问题。 ARM 没有 gcc-multilib 等效项,因此您必须安装 gcc-multilib-arm-linux-gnueabihf 才能正常工作。尝试使用 Clang 进行编译和定位时,您必须首先

cd /usr/include/aarch64-linux-gnu

然后

sudo cp -r . ..

这是一个 hacky 解决方案,但它可以让您导入您认为合适的库