问题描述
当尝试使用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
我尝试以不同的方式进行编译,并且还尝试按照.abash_profile中的LD_LIBRARY_PATH进行设置,如 https://gcc.gnu.org/wiki/GFortranBinaries32Linux ,但我仍然遇到相同的错误. gfortran目录的路径名为:/usr/local/gfortran,但是可以在/usr/local/bin
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?
任何帮助将不胜感激!
推荐答案
我遇到了同样的问题,但是使用自制软件从gcc软件包安装gfortran构建没有帮助.相反,我使用自制软件安装了整个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的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!