本文介绍了GFortran 错误:ld:尝试编译时找不到 -lSystem 的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在尝试使用 gfortran 编译一个简单的 fortran-90 文件时遇到一个奇怪的错误.我正在使用 macOS mojave 系统.我安装了 gfortran 8.2.0,并通过执行以下操作来检查以确保这一点:

I am getting a strange error when trying to compile a simple fortran-90 file using gfortran. I am working on a macOS mojave system. I have gfortran 8.2.0 installed and I checked to be sure of this by doing the following:

Input: gfortran --version
Output: GNU Fortran (GCC) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

这表明 gfortran 安装正确,我也通过在终端中简单地键入:gfortran 来确认这一点,它返回:

Which indicates that gfortran installed correctly and I also confirmed this by typing simply: gfortran, into the terminal, which returns:

gfortran: fatal error: no input files
compilation terminated.

但是,当我尝试像这样编译我的文件时:

However, when I try to compile my file like so:

gfortran hello.f90 -o hello.x

我收到一个错误消息:

ld: library not found for -lSystem
collect2: error: ld returned 1 exit status

我尝试以不同的方式编译,我也尝试在 .bash_profile 中设置 LD_LIBRARY_PATH,如 https 所述://gcc.gnu.org/wiki/GFortranBinaries32Linux 但我仍然遇到同样的错误.gfortran 目录的路径名是:/usr/local/gfortran,但是在/usr/local/bin 中可以找到另一个不是目录的 gfortran

I've tried compiling in different ways and I also tried setting the LD_LIBRARY_PATH in .bash_profile as described by https://gcc.gnu.org/wiki/GFortranBinaries32Linux but I still get the same error. The gfortran directory has the pathname: /usr/local/gfortran, however another gfortran which is not a directory can be found in /usr/local/bin

输入:

which gfortran

输出:

/usr/local/bin/gfortran

以及对该目录的长列表搜索:

And a long list search of this directory:

Input: ls -l /usr/local/bin/gfortran
Output: lrwxr-xr-x  1 root  wheel  32 15 May 14:07
/usr/local/bin/gfortran -> /usr/local/gfortran/bin/gfortran

如果一切似乎都正确安装,我该如何解决这个问题?

How can I fix this where everything seems to be correctly installed?

任何帮助将不胜感激!

推荐答案

我遇到了同样的问题,但是使用 homebrew 从 gcc 包安装 gfortran build 没有帮助.相反,我使用自制软件安装了整个 gcc:

I had the same problem, but installing gfortran build from the gcc package using homebrew did not help. Instead, I installed the whole gcc using homebrew:

brew install gcc

这样就解决了问题.

这篇关于GFortran 错误:ld:尝试编译时找不到 -lSystem 的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 11:20