You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在OpenBSD上编译含libgccjit的GCC时遇找不到libc.a错误

解决OpenBSD7.5编译GCC13时libgomp阶段找不到libc的问题

问题背景

克隆GCC13仓库后,在build目录执行指定configure命令:

../configure --enable-host-shared --enable-languages=jit,c++ --disable-bootstrap --enable-checking=release --prefix=/usr/local --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --build=x86_64-unknown-openbsd$(uname -r) --host=x86_64-unknown-openbsd$(uname -r) --target=x86_64-unknown-openbsd$(uname -r) --prefix=/home/kabiraatmonallabs/Execution/Runtime --enable-threads --disable-multilib --enable-lto --disable-libstdcxx-pch --with-system-zlib --with-gnu-as -with-gnu-ld

执行gmake时在x86_64-unknown-openbsd7.5/libgomp目录失败,config.log显示链接器无法找到-lc,但系统默认的/usr/lib目录下存在libc.so和libc.a。

问题原因

  1. configure命令中重复指定了两次--prefix,最终自定义的prefix路径导致临时编译器xgcc默认仅在该路径下查找库和头文件,忽略了OpenBSD系统默认的/usr/lib和/usr/include。
  2. 编译过程中的临时xgcc尚未完成安装,不会自动识别系统默认的库和头文件路径,必须显式指定。

解决方案

1. 修正configure命令

  • 删除重复的--prefix=/usr/local参数,保留最终的自定义prefix
  • 添加--with-native-system-header-dir=/usr/include指定系统头文件位置
  • 添加LDFLAGS=-L/usr/lib让链接器能找到/usr/lib下的系统库

修正后的完整configure命令:

../configure --enable-host-shared --enable-languages=jit,c++ --disable-bootstrap --enable-checking=release --prefix=/home/kabiraatmonallabs/Execution/Runtime --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --build=x86_64-unknown-openbsd$(uname -r) --host=x86_64-unknown-openbsd$(uname -r) --target=x86_64-unknown-openbsd$(uname -r) --enable-threads --disable-multilib --enable-lto --disable-libstdcxx-pch --with-system-zlib --with-gnu-as --with-gnu-ld --with-native-system-header-dir=/usr/include LDFLAGS=-L/usr/lib

2. 清理并重新编译

# 清理之前的build目录残留
rm -rf build/*
cd build
# 执行上面修正后的configure命令
gmake -j$(nproc)

额外注意事项

  • 确保/usr/lib下的libc.so和libc.a权限正常,当前用户拥有读取权限
  • OpenBSD环境下编译GCC时,临时编译器的路径依赖必须显式指定,否则容易出现系统库查找失败的问题

内容的提问来源于stack exchange,提问作者Kabira K

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 10:02:17