CentOS 上 Fortran 库文件的常见位置与排查方法
一、系统默认库目录
二、快速定位与验证
sudo find / -name "libgfortran.so*"locate libgfortran.so(需先 sudo updatedb)ldd your_app | grep libgfortranld --verbose | grep SEARCH_DIRgfortran -L/usr/local/lib64 -lgfortran your.f90LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH ./your_app三、兼容旧程序需要 libgfortran.so.3 的处理(CentOS 8/RHEL 8/Rocky 8)
error while loading shared libraries: libgfortran.so.3: cannot open shared object file。sudo dnf install epel-release -ysudo dnf install compat-libgfortran-48 -yls -l /usr/lib64/libgfortran.so.3ldd ./your_old_app | grep libgfortran(应看到指向 libgfortran.so.3)ln -s /usr/lib64/libgfortran.so.5 /usr/lib64/libgfortran.so.3,否则可能导致段错误或结果错误。四、源码安装或第三方库的默认路径与配置
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATHexport CPPFLAGS=-I/usr/local/includeexport LDFLAGS=-L/usr/local/libmodule show 库名 查看其 LIBRARY_PATH/INCLUDE 等设置。