缺少aarch64 gcc库

wljmcqd8  于 2023-02-23  发布在  其他
关注(0)|答案(1)|浏览(248)

I've installed the aarch64-linux-gnu-gcc-8 gcc compiler on an x86 debian distro and am not able to build code due to missing libraries.
The libraries have obviously not been installed when I installed aarch64 version of gcc - but I cannot work out how to install them. Below is the full build output, but it is clear that these two lines tell the story:

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

How do you install the aarch64 standard libraries for cross compiling on x86 linux?
Here is how I installed gcc aarch64:

sudo apt install gcc-8-aarch64-linux-gnu
sudo apt install qemu
sudo apt install gdb-multiarch

Full build output:
$ aarch64-linux-gnu-gcc-8 -o arm64main hello.c -v -static Using built-in specs. COLLECT_GCC=aarch64-linux-gnu-gcc-8 COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/8/lto-wrapper Target: aarch64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --disable-libphobos --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include Thread model: posix gcc version 8.3.0 (Debian 8.3.0-2) COLLECT_GCC_OPTIONS='-o' 'arm64main' '-v' '-static' '-mlittle-endian' '-mabi=lp64' /usr/lib/gcc-cross/aarch64-linux-gnu/8/cc1 -quiet -v -imultiarch aarch64-linux-gnu hello.c -quiet -dumpbase hello.c -mlittle-endian -mabi=lp64 -auxbase hello -version -o /tmp/ccR3mCkw.s GNU C17 (Debian 8.3.0-2) version 8.3.0 (aarch64-linux-gnu) compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/include/aarch64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/include" ignoring nonexistent directory "/usr/include/aarch64-linux-gnu" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc-cross/aarch64-linux-gnu/8/include /usr/lib/gcc-cross/aarch64-linux-gnu/8/include-fixed /usr/include End of search list. GNU C17 (Debian 8.3.0-2) version 8.3.0 (aarch64-linux-gnu) compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 85d021a8c445ff17fea6865e03920e8f In file included from hello.c:1: /usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory #include <bits/libc-header-start.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.

ecbunoof

ecbunoof1#

简短回答:你没有丢失任何东西!执行file命令显示你已经创建了你想要的二进制文件:

$ file arm64main
arm64main: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.7.0, BuildID[sha1]=82bc100420a39fb0555d1971aafc488669d3f71c, not stripped

最甜蜜的演示:M. Mossberg的博客展示了如何用qemu运行这个二进制文件,并用gdb-multiarch进行调试。How to set up an ARM64 playground on Ubuntu 18.04
相关:JensD的博客将向您介绍整个过程:在Debian或Ubuntu上为Arm或Aarch64交叉编译
详细回答:此LinuxFoundation视频用大约50分钟的时间解释GCC交叉编译工具链Anatomy of Cross-Compilation Toolchains--Thomas Petazzoni, Free Electrons

相关问题