我尝试为我的设备找出三元组,因为我尝试交叉编译,但目标设备上没有安装 gcc,我不允许安装它。
安装 gcc 后,我可以写 gcc -dumpmachine
没有gcc是否可以找到这些信息?
您可以uname通过检查file可执行文件的类型来获取大量信息:
$ gcc -dumpmachine
x86_64-linux-gnu
$ uname -o -m
x86_64 GNU/Linux
$ file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d8ac02806880576708bf189c064fca78ea89f1d0, stripped
Run Code Online (Sandbox Code Playgroud)
如果您的设备尚未file安装,请将二进制可执行文件从中复制到另一台 Linux 计算机并在file那里运行。
您需要在文件系统中找到保留在configure目标用户空间的构建时间传递给/探测的三元组的文件。
在常见的 GNU/Linux 发行版中,最好的选择是查询常见的命令二进制文件,例如bash curl make svn. 在Debian/armhf的以下示例中(从此处获取的 QEMU 图像),我通过获得了规范三元组。因此,通过 为该系统配置我的交叉工具链基本上是安全的。arm-unknown-linux-gnueabihfbash --version/path/to/configure --target=arm-unknown-linux-gnueabihf
root@debian-armhf:~# bash --version
GNU bash, version 4.2.37(1)-release (arm-unknown-linux-gnueabihf)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Run Code Online (Sandbox Code Playgroud)
没有可靠的方法可以arm-linux-gnueabihf x86_64-linux-gnu从用户空间了解非规范三元组,并且可能存在特定于发行版的约定,例如 Debian multiarch和tuples。您需要从您的发行版文档或其他在线资源中收集信息。