我正在尝试在macOS Sierra上安装wgrib2。我已经按照this blog上的说明进行操作了。这是终端中发生的事情:

rm tmpaec.tar
cd "/usr/local/grib2/libaec-1.0.0" && export CFLAGS="-I/usr/local/grib2/include -Wall -Wmissing-prototypes -Wold-style-definition -Werror=format-security --fast-math -O3 -DGFORTRAN -fopenmp -I/usr/local/grib2/jasper-1.900.1/src/libjasper/include -I/usr/include " && ./configure --disable-shared --prefix=/usr/local/grib2 && make check install
checking build system type... x86_64-apple-darwin16.7.0
checking host system type... x86_64-apple-darwin16.7.0
checking how to print strings... printf
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/usr/local/grib2/libaec-1.0.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** [/usr/local/grib2/lib/libaec.a] Error 77

这是我可以在config.log中阅读的内容:
configure:2882: gcc -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:2893: $? = 1
configure:2882: gcc -qversion >&5
clang: error: unknown argument: '-qversion'
clang: error: no input files
configure:2893: $? = 1
configure:2913: checking whether the C compiler works
configure:2935: gcc -I/usr/local/grib2/include -Wall -Wmissing-prototypes -Wold-style-definition -Werror=format-security --fast-math -O3 -DGFORTRAN -fopenmp -I/usr/local/grib2/jasper-1.900.1/src/libjasper$
clang: error: unsupported option '--fast-math'
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
configure:2939: $? = 1
configure:2977: result: no
configure: failed program was:

我该如何解决这个问题?

最佳答案

您未使用gcc,而是根据看到的clang: error:行使用了clang

Clang将自己描述为与gcc兼容的编译器,但不是gcc。如您所链接的博客文章所述,就libaec而言,clang可能会触发构建错误。发布wgrib2的NWS气候预测中心提供了specific recommendations,以供您使用c创建wgrib2时使用,但我无法使其正常工作。

最好的解决方案是改用gcc。您链接到的blog post确实具有使用homebrew进行安装的说明:

brew install gcc

然后按照wgrib2的构建说明进行操作:
export CC=gcc-9   # Use the version listed in `ls /usr/local/bin/gcc-*`, not clang gcc
export FC=gfortran
make

那应该可以解决您的libaec问题,然后wgrib2应该可以成功编译。

10-04 17:22