我在 netCDF Fortran 编译方面遇到问题。这是我编译的输出:
configure: netCDF-Fortran 4.5.3
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
configure: checking user options
checking whether make supports the include directive... yes (GNU style)
checking for gcc... /home/ksenia/prgs4mom/openmpi_4.1.1/bin/mpicc
checking whether the C compiler works... no
configure: error: in `/home/ksenia/prgs4mom/src/netcdf-fortran-4.5.3':
configure: error: C compiler cannot create executables
See config.log for more details
make: *** No targets specified and no makefile found. Stop.
这是我的编译脚本:
#!/bin/bash
export CC="/home/ksenia/prgs4mom/openmpi_4.1.1/bin/mpicc"
export FC="/home/ksenia/prgs4mom/openmpi_4.1.1/bin/mpif90"
export F77="/home/ksenia/prgs4mom/openmpi_4.1.1/bin/mpifort"
export CXX="/home/ksenia/prgs4mom/openmpi_4.1.1/bin/mpicxx"
export CPPFLAGS="$(echo "nc-config --cflags")"
export LDFLAGS="$(echo "nc-config --libs")"
export LIBS="-lnetcdf"
export CFLAGS="-DgFortran"
export CPPLAGS="-DgFortran"
export CXXFLAGS="-DgFortran"
./configure --disable-shared --prefix=/home/ksenia/prgs4mom/netcdf_fortran_4.5.3
make && sudo make install
还应该注意的是,如果我注释提供 LDFLAGS、CPPFLAGS 和 LIBS 的字符串,编译将以另一种可以理解的方式进行(为了更方便查看,我剪切了输出):
configure: netCDF-Fortran 4.5.3
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
configure: checking user options
checking whether make supports the include directive... yes (GNU style)
checking for gcc... /home/ksenia/prgs4mom/openmpi_4.1.1/bin/mpicc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
***
configure: error: netcdf-c version 4.7.4 or greater is required
make: *** No targets specified and no makefile found. Stop.
这是
nc-config --all
的输出:
This netCDF 4.7.4 has been built with the following features:
--cc -> /home/ksenia/prgs4mom/openmpi_4.1.1/bin/mpicc
--cflags -> -I/home/ksenia/prgs4mom/netcdf_c_4.7.4/include -I/home/ksenia/prgs4mom/zlib_1.2.11/include -I/home/ksenia/prgs4mom/curl_7.77.0/include -I/usr/lib/gcc/x86_64-linux-gnu/9/include -I/usr/include -I/home/ksenia/prgs4mom/openmpi_4.1.1/include -I/home/ksenia/prgs4mom/hdf5_1.12.0/include -I/home/ksenia/prgs4mom/pnetcdf_1.12.2/include
--libs -> -L/home/ksenia/prgs4mom/netcdf_c_4.7.4/lib -L/home/ksenia/prgs4mom/zlib_1.2.11/lib -L/home/ksenia/prgs4mom/curl_7.77.0/lib -L/usr/lib -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/home/ksenia/prgs4mom/openmpi_4.1.1/lib -L/home/ksenia/prgs4mom/hdf5_1.12.0/lib -L/home/ksenia/prgs4mom/pnetcdf_1.12.2/lib -lnetcdf -lpnetcdf -lhdf5_hl -lhdf5 -lm -ldl -lz -lcurl
--static -> -lpnetcdf -lhdf5_hl -lhdf5 -lm -ldl -lz -lcurl
--has-c++ -> no
--cxx ->
--has-c++4 -> no
--cxx4 ->
--has-fortran -> no
--has-dap -> yes
--has-dap2 -> yes
--has-dap4 -> yes
--has-nc2 -> yes
--has-nc4 -> yes
--has-hdf5 -> yes
--has-hdf4 -> no
--has-logging -> no
--has-pnetcdf -> yes
--has-szlib -> no
--has-cdf5 -> yes
--has-parallel4 -> yes
--has-parallel -> yes
--prefix -> /home/ksenia/prgs4mom/netcdf_c_4.7.4
--includedir -> /home/ksenia/prgs4mom/netcdf_c_4.7.4/include
--libdir -> /home/ksenia/prgs4mom/netcdf_c_4.7.4/lib
--version -> netCDF 4.7.4
如果我提供有关 netCDF-C 的信息以及如何修复它,有人可以向我解释一下我做错了什么以及为什么配置回顾我的 PC 上没有可用的 C 编译器吗?
谢谢!
我在运行 Ventura 的 Macbook Pro 上尝试安装 WRF 和 netCDF 时遇到了同样的问题。在其中一个安装 shell 脚本中,它坚持以超级用户身份运行该脚本。所以我就这么做了
sudo ./配置
并且编译克服了C编译器问题的这个问题。还有其他与路径设置等相关的问题,需要注意。