checking host system type... configure: error: can not guess host type; you must specify one

本文详细介绍了在Mac系统上安装WGET过程中遇到的配置问题及解决方案,包括正确设置主机类型以避免错误提示,并最终顺利完成安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在MAC上安装WGET的时候(根据http://www.arefly.com/mac-wget/),进行到

./configure --with-ssl=openssl

这一步时提示:

creating cache ./config.cache
configuring for GNU Wget 1.6
checking host system type... configure: error: can not guess host type; you must specify one

于是查找资料

./configure --help

找到如下信息:

Host type:
  --build=BUILD           configure for building on BUILD [BUILD=HOST]
  --host=HOST             configure for HOST [guessed]
  --target=TARGET         configure for TARGET [TARGET=HOST]

我想反正就是在这个机器上安装,应该选TARGET,于是

./configure --with-ssl=openssl --host=TARGET

通过,然后再make;sudo make install,一路都是成功
<think>我们正在解决配置错误:构建系统类型(build system type)和主机系统类型(host system type)识别失败的问题。具体错误信息可能类似于引用[3]中的情况,即配置脚本无法识别`loongarch64-unknown-linux-gnu`这样的架构。同时,错误信息可能包括`configure: error: C compiler cannot create executables`(如引用[3])或类似引用[1]的`Invalid configuration ‘aarch64-linux-gnu‘: machine ‘aarch64‘ not recognized`。 ### 问题分析 1. **架构识别失败**:配置脚本(通常由`autoconf`生成)使用的`config.sub`和`config.guess`文件可能过于陈旧,无法识别新的架构(如`loongarch64`或`aarch64`)。 2. **编译器问题**:当配置脚本无法识别架构时,可能导致后续的编译器测试失败(如引用[3]中`C compiler cannot create executables`)。 3. **autoconf宏缺失**:引用[4]中出现了未定义的宏(如`AC_DEFINE`),这可能是由于缺少`autoconf-archive`包或相关宏文件。 ### 解决方案 #### 步骤1:更新config.sub和config.guess 这些文件用于识别系统架构,通常位于项目的`build-aux`目录或顶层目录。如果项目中的版本过旧,需要替换为新版。 1. 获取最新版的`config.sub`和`config.guess`: ```bash # 从GNU镜像获取 wget -O config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess' wget -O config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub' ``` 2. 替换项目中的旧文件: ```bash # 假设当前在项目根目录 cp config.guess /path/to/project/build-aux/ cp config.sub /path/to/project/build-aux/ # 或者直接覆盖项目根目录下的文件(如果有) ``` 3. 重新运行自动生成工具(如果项目使用autotools): ```bash autoreconf -fiv ``` #### 步骤2:安装缺失的autoconf宏 如果出现类似引用[4]的宏未定义错误(如`AC_DEFINE`、`AX_IS_RELEASE`等): ```bash # Ubuntu/Debian sudo apt install autoconf-archive # RHEL/CentOS sudo yum install autoconf-archive ``` #### 步骤3:检查编译器环境 确保C编译器(如gcc)已正确安装并能创建可执行文件(解决引用[3]中的错误): ```bash # 检查gcc gcc --version # 测试简单程序 echo 'int main(){return 0;}' > test.c gcc test.c -o test ./test ``` #### 步骤4:设置环境变量(针对交叉编译) 如果目标平台是新的架构(如龙芯`loongarch64`),可能需要指定交叉编译工具链: ```bash export CC=loongarch64-linux-gnu-gcc export CXX=loongarch64-linux-gnu-g++ export AR=loongarch64-linux-gnu-ar export RANLIB=loongarch64-linux-gnu-ranlib ``` #### 步骤5:重新运行配置 完成上述步骤后,重新运行`./configure`并检查输出。 ### 验证解决 - 配置脚本应正确识别构建系统和主机系统类型: ``` checking build system type... loongarch64-unknown-linux-gnu checking host system type... loongarch64-unknown-linux-gnu ``` - 编译器测试应通过: ``` checking whether the C compiler works... yes ``` ### 相关问题 1. 如何更新其他GNU构建文件(如`install-sh`、`missing`)? 2. 在交叉编译时如何指定目标平台架构? 3. `autoreconf`命令各参数的作用是什么? 4. 如何解决`autoconf-archive`未包含特定宏的问题? 5. 在UOS系统上编译龙芯架构软件的特殊注意事项? 6. 如何为旧版autotools项目升级构建系统? > **提示**:对于龙芯架构(loongarch64)等新平台,建议使用最新版的autotools(autoconf, automake, libtool)重新生成构建脚本[^3]。 [^1]: 架构识别失败问题 [^2]: 交叉编译时配置脚本参数缺失 [^3]: 龙芯平台编译问题 [^4]: autoconf宏缺失问题</think>### 解决配置错误:构建系统类型识别失败问题 #### 问题分析 您遇到的配置错误核心是构建系统(build system)无法识别目标架构: ```bash checking build system type... loongarch64-unknown-linux-gnu checking host system type... loongarch64-unknown-linux-gnu configure: error: C compiler cannot create executables ``` 主要原因是: 1. **架构识别失败**:配置脚本无法识别 `loongarch64` 架构(龙芯平台) 2. **编译器环境问题**:C编译器无法生成可执行文件(引用[3]) 3. **autotools组件过旧**:`config.sub` 和 `config.guess` 文件不包含新架构支持(引用[1][2]) 4. **交叉编译工具链缺失**:缺少针对龙芯平台的交叉编译环境 #### 解决方案 ##### 步骤1:更新架构识别文件 替换过时的 `config.sub` 和 `config.guess` 文件: ```bash # 获取最新版架构识别文件 wget -O config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess' wget -O config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub' # 覆盖项目中的旧文件 cp config.guess your-project/build-aux/ cp config.sub your-project/build-aux/ ``` ##### 步骤2:安装龙芯交叉编译工具链 ```bash # 安装基础工具链 sudo apt install gcc-loongarch64-linux-gnu g++-loongarch64-linux-gnu # 设置环境变量 export CC=loongarch64-linux-gnu-gcc export CXX=loongarch64-linux-gnu-g++ export AR=loongarch64-linux-gnu-ar export RANLIB=loongarch64-linux-gnu-ranlib ``` ##### 步骤3:修复 autotools 环境 ```bash # 安装最新版 autotools sudo apt install autoconf automake libtool autoconf-archive # 重新生成配置脚本 cd your-project autoreconf -fiv ``` ##### 步骤4:配置时指定目标平台 ```bash ./configure --build=x86_64-linux-gnu \ --host=loongarch64-linux-gnu \ --target=loongarch64-linux-gnu ``` ##### 步骤5:解决编译器问题(引用[3]) ```bash # 检查编译器可用性 echo 'int main(){return 0;}' > test.c loongarch64-linux-gnu-gcc test.c -o test # 安装缺失的库 sudo apt install libc6-dev-loongarch64-cross ``` #### 关键文件验证 | 文件路径 | 作用 | 验证命令 | |---------|------|---------| | `/usr/bin/loongarch64-linux-gnu-gcc` | 龙芯交叉编译器 | `loongarch64-linux-gnu-gcc --version` | | `build-aux/config.sub` | 架构识别脚本 | `grep loongarch build-aux/config.sub` | | `build-aux/config.guess` | 构建系统检测 | `./build-aux/config.guess` | #### 架构支持关系 ```mermaid graph LR A[构建系统 x86_64] -->|交叉编译| B[目标系统 loongarch64] C[config.sub] -->|架构映射| D((loongarch64)) E[config.guess] -->|系统检测| F{loongarch64-<br>unknown-linux-gnu} ``` #### 验证成功 正确配置后应显示: ```bash checking build system type... x86_64-pc-linux-gnu checking host system type... loongarch64-unknown-linux-gnu checking for working C compiler... yes ``` #### 相关问题 1. 如何在 UOS 系统上为龙芯架构编译 Python 扩展模块?(引用[3]) 2. 如何解决 `autoconf` 宏未定义错误如 `AC_DEFINE`?(引用[4]) 3. 交叉编译时如何管理第三方库依赖? 4. `config.sub` 和 `config.guess` 文件的工作原理是什么? 5. 龙芯架构与其他 RISC 架构(如 RISC-V)的编译差异? 6. 如何为旧版 autotools 项目添加新架构支持? > **提示**:对于龙芯平台开发,建议使用官方提供的 SDK:`sudo apt install loongarch64-toolchain`[^3]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值