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

如何解决“加载共享库时出错:libgfortran.so.4未找到”问题

解决libgfortran.so.4缺失报错问题

问题描述

运行程序时触发如下报错:

error while loading shared libraries: libgfortran.so.4: cannot open shared object file: No such file or directory

尝试通过教程中的命令安装依赖失败,具体错误如下:

  • 执行sudo add-apt-repository ppa:jonathonf/gcc-7.1,提示ERROR: ppa 'jonathonf/gcc-7.1' not found
  • 执行sudo apt-get install gcc-7 g++-7,提示E: Package 'gcc-7' has no installation candidate
  • 执行sudo apt-get install gfortran-7,提示E: Unable to locate package gfortran-7

解决方案

方法1:替换为可用PPA安装gfortran-7

原PPA已停止维护,使用Ubuntu官方工具链PPA:

  1. 添加PPA并更新源:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
  1. 安装gfortran-7(自动包含libgfortran.so.4):
sudo apt-get install gfortran-7

方法2:手动下载deb包安装libgfortran4

若PPA无法访问,直接下载对应架构的deb包:

  1. 找到Ubuntu 16.04版本的libgfortran4 deb包(匹配你的系统架构:amd64/i386)
  2. 执行安装命令(替换为实际包名):
sudo dpkg -i libgfortran4_7.5.0-3ubuntu1~16.04_amd64.deb

方法3:临时软链接方案(不推荐长期使用)

如果系统中有更高版本的libgfortran,可临时创建软链接应急:

  1. 查找已安装的libgfortran文件:
find /usr/lib -name "libgfortran.so*"
  1. 假设找到libgfortran.so.5,创建软链接:
sudo ln -s /usr/lib/x86_64-linux-gnu/libgfortran.so.5 /usr/lib/x86_64-linux-gnu/libgfortran.so.4

(路径需根据实际查找结果调整)


内容的提问来源于stack exchange,提问作者Madhu Sudan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 03:32:23