在 x86-64 上使用 clang-11 交叉编译 aarch64-linux-gnu 错误:'bits/c++config.h'找不到文件

发布于 2025-01-10 07:42:03 字数 3421 浏览 0 评论 0原文

我正在尝试使用 clang-11 将 c++ 文件从我的 x86-64 主机交叉编译为 aarch-linux-gnu。

这是命令: clang-11 -v -target aarch64-linux-gnu -B/usr/aarch64-linux-gnu/lib -march=armv8.5-a+memtag -fsanitize=memtag test_mte.cpp -static

但是,我遇到了这个错误:

In file include from /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/stdlib.h:36:/usr/bin /../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/cstdlib:41:10:致命错误:找不到“bits/c++config.h”文件 #include

我已经安装了软件包 gcc-multilib g++-multilib binutils-aarch64-linux- gnu libc6-arm64-cross libc6-dev-arm64-cross crossbuild-essential-arm64 gcc-aarch64-linux-gnu

如何解决此错误?

完整输出: 以下是 clang-11 命令的完整输出:

`Debian clang version 11.0.1-2~bpo10+1

Target: aarch64-unknown-linux-gnu

Thread model: posix InstalledDir: /usr/bin

找到候选 GCC 安装:/usr/bin/../

lib/gcc-cross/aarch64-linux-gnu/8 找到候选 GCC 安装:/usr/lib/gcc-cross/aarch64-linux- gnu/8

选定的 GCC 安装:/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8

候选 multilib:.;@m64

选定multilib: .;@m64

"/usr/lib/llvm-11/bin/clang" -cc1 -triple aarch64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -丢弃值名称-主文件名 test_mte.cpp -static-define -mrelocation-model static -mframe-pointer=non-leaf -fmath-errno -fno-rounding-math -mconstructor-aliases -target-cpu generic -target-feature +neon -target-feature +v8.5a -target-feature +mte -t​​arget-abi aapcs -fallow-half-argum ents-and-returns -fno-split-dwarf-inlined -debugger-tuning=gdb -v -resource-dir /usr/lib/llvm-11/lib/clang/11.0.1 -internal-isystem /usr/bi n/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/ gcc-cross/aarch64-linux-gnu/8/../../../.. /include/aarch64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../包括/aarch64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem / usr/local/包含-in 外部 isystem /usr/lib/llvm-11/lib/clang/11.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdepreca ted-macro -fdebug-compilation-dir /home/aditi712/mte_Stuff -ferror-limit 19 -fsanitize=memtag -fno-signed-char -fgnuc-version=4.2.1 -fcxx-ex ceptions -fexceptions -fcolor-diagnostics -faddrsig -o /tmp/test_mte-836487.o -x c++ test_mte.cpp

clang -cc1 版本 11.0.1 基于 LLVM 11.0.1 默认目标 x86_64-pc-linux-gnu

忽略不存在的目录“/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/aarch64-linux-gnu/c++/8”

忽略不存在的目录“/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/aarch64-linux-gnu/c++/8”

忽略不存在的目录"/include"

#include "..." 搜索从此处开始:

#include <...>搜索从这里开始:

/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8

/usr/bin/.. /lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/backward

/usr/local/include

/usr/lib/llvm-11/lib/clang/11.0.1/include

/usr/include

搜索列表结束。 在 test_mte.cpp:7 包含的文件中:

在 /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/ 包含的文件中c++/8/stdlib.h:36:

/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/cstdlib:41:10:致命错误:'找不到位/c++config.h'文件

#include`

I am trying to use clang-11 to cross compile a c++ file to aarch-linux-gnu, from my host machine which is x86-64.

Here's the command :
clang-11 -v -target aarch64-linux-gnu -B/usr/aarch64-linux-gnu/lib -march=armv8.5-a+memtag -fsanitize=memtag test_mte.cpp -static

But, I run into this error:

In file included from /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/stdlib.h:36: /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/cstdlib:41:10: fatal error: 'bits/c++config.h' file not found #include <bits/c++config.h>

I have installed the packages gcc-multilib g++-multilib binutils-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross crossbuild-essential-arm64 gcc-aarch64-linux-gnu

How can I resolve this error?

Full Output:
Here's the full output of the clang-11 command:

`Debian clang version 11.0.1-2~bpo10+1

Target: aarch64-unknown-linux-gnu

Thread model: posix
InstalledDir: /usr/bin

Found candidate GCC installation: /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8

Found candidate GCC installation: /usr/lib/gcc-cross/aarch64-linux-gnu/8

Selected GCC installation: /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8

Candidate multilib: .;@m64

Selected multilib: .;@m64

"/usr/lib/llvm-11/bin/clang" -cc1 -triple aarch64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test_mte.cpp -static-define -mrelocation-model static -mframe-pointer=non-leaf -fmath-errno -fno-rounding-math -mconstructor-aliases -target-cpu generic -target-feature +neon -target-feature +v8.5a -target-feature +mte -target-abi aapcs -fallow-half-argum
ents-and-returns -fno-split-dwarf-inlining -debugger-tuning=gdb -v -resource-dir /usr/lib/llvm-11/lib/clang/11.0.1 -internal-isystem /usr/bi
n/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../..
/include/aarch64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/aarch64-linux-gnu/c++/8
-internal-isystem /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/local/include -in
ternal-isystem /usr/lib/llvm-11/lib/clang/11.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdepreca
ted-macro -fdebug-compilation-dir /home/aditi712/mte_Stuff -ferror-limit 19 -fsanitize=memtag -fno-signed-char -fgnuc-version=4.2.1 -fcxx-ex
ceptions -fexceptions -fcolor-diagnostics -faddrsig -o /tmp/test_mte-836487.o -x c++ test_mte.cpp

clang -cc1 version 11.0.1 based upon LLVM 11.0.1 default target x86_64-pc-linux-gnu

ignoring nonexistent directory "/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/aarch64-linux-gnu/c++/8"

ignoring nonexistent directory "/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/aarch64-linux-gnu/c++/8"

ignoring nonexistent directory "/include"

#include "..." search starts here:

#include <...> search starts here:

/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8

/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/backward

/usr/local/include

/usr/lib/llvm-11/lib/clang/11.0.1/include

/usr/include

End of search list.
In file included from test_mte.cpp:7:

In file included from /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/stdlib.h:36:

/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/8/../../../../include/c++/8/cstdlib:41:10: fatal error: 'bits/c++config.h' file not found

#include <bits/c++config.h>`

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野侃 2025-01-17 07:42:03

在我看来,clang 正在询问一些 gcc 有关系统包含路径的信息,并且此过程失败(由于某种原因),导致包含主机头。

这是一个对我有帮助的解决方案:
https://askubuntu.com/questions/947954/wrong-default- include-directories-for-clang-cross-compile

基本上,您自己提供所有系统包含内容。在我们的例子(arm64)中,对我来说这可以归结为这些标志:

-nostdinc++ 
-cxx-isystem /usr/aarch64-linux-gnu/include/c++/10/`
-cxx-isystem /usr/aarch64-linux-gnu/include/c++/10/aarch64-linux-gnu/
-isystem /usr/aarch64-linux-gnu/include

It seems to me that clang is asking some gcc about system include paths, and this process fails (for some reason), leading to inclusion of host headers.

Here is a solution that helped me:
https://askubuntu.com/questions/947954/wrong-default-include-directories-for-clang-cross-compile

Basically you provide all system includes on your own. In our case (arm64), for me this boiled down to these flags:

-nostdinc++ 
-cxx-isystem /usr/aarch64-linux-gnu/include/c++/10/`
-cxx-isystem /usr/aarch64-linux-gnu/include/c++/10/aarch64-linux-gnu/
-isystem /usr/aarch64-linux-gnu/include
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文