Netcdf-Fortran 安装-CC 不可执行

Netcdf-Fortran 安装-CC 不可执行

我正在尝试安装 fortran 的 netcdf 模块。我按照此链接中的步骤操作http://albeniz.eng.uci.edu/software/WRFCMAQ/NetCDF_installation_for_C_and_Fortran_libraries-HPC.pdf

我收到错误:

configure: netCDF 4.4.1.1
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-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... /bin/mkdir -p
checking for gawk... gawk
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 a win32 DLL is desired... no
checking whether a NCIO_MINBLOCKSIZE was specified... 256
checking if fsync support is enabled... no
checking if jna bug workaround is enabledd... no
checking whether extra valgrind tests should be run... no
checking whether we should build netCDF-4... no
checking do we require hdf5 dynamic-loading support... yes
checking whether reading of HDF4 SD files is to be enabled... no
checking whether to fetch some sample HDF4 files from Unidata ftp site to test HDF4 reading (requires wget)... no
checking whether we should attempt to install netcdf-fortran (EXPERIMENTAL)... no
checking whether extra example tests should be run... no
checking whether parallel IO tests should be run... no
checking whether a default chunk size in bytes was specified... 4194304
checking whether a maximum per-variable cache size for HDF5 was specified... 67108864
checking whether a number of chunks for the default per-variable cache was specified... 10
checking whether a default file cache size for HDF5 was specified... 4194304
checking whether a default file cache maximum number of elements for HDF5 was specified... 1009
checking whether a default cache preemption for HDF5 was specified... 0.75
checking whether netCDF-4 logging is enabled... no
checking whether DAP client is to be built... no
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/mirzaba/test/FSM2/srcNETCDF/netcdf-4.4.1.1':
configure: error: C compiler cannot create executables
See `config.log' for more details

这是我的 config.log

## ---------------- ##

ac_cv_build=x86_64-unknown-linux-gnu
ac_cv_env_CC_set=set
ac_cv_env_CC_value=gcc
ac_cv_env_CFLAGS_set=set
ac_cv_env_CFLAGS_value=-O
ac_cv_env_CPPFLAGS_set=set
ac_cv_env_CPPFLAGS_value='-DNDEBUG -DgFortran'
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_LT_SYS_LIBRARY_PATH_set=
ac_cv_env_LT_SYS_LIBRARY_PATH_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_host=x86_64-unknown-linux-gnu
ac_cv_path_install='/usr/bin/install -c'
ac_cv_path_mkdir=/bin/mkdir
ac_cv_prog_AWK=gawk
ac_cv_prog_ac_ct_CC=gcc
ac_cv_prog_make_make_set=yes
ac_cv_target=x86_64-unknown-linux-gnu
am_cv_make_support_nested_variables=yes

## ----------------- ##
## Output variables. ##
## ----------------- ##

                                                                                             167,1         37%

答案1

如果您确实想从源代码安装 netcdf,则需要排除以下错误:

configure: error: C compiler cannot create executables

导致错误的一些可能原因包括

  • 编译器或链接器安装不正确

  • 您的其他位置的不兼容链接器PATH

  • noexec使用选项挂载目标目录所在的文件系统


libnetcdf-dev但是 Ubuntu “universe” 存储库已经包含针对 C/C++ ( ) 和 Fortran ( ) netcdf ABI的预构建软件包libnetcdff-dev。因此,如果您的真正目标只是从 github 存储库构建具有 netcdf 支持的 FSM2,您需要做的就是:

  • 如果尚未启用 Universe 存储库,请参阅例如我如何启用“Universe”存储库?

  • 安装libnetcdff-dev包(将安装 C/C++ dev 和运行时包作为依赖项)

     sudo apt update && sudo apt install libnetcdff-dev
    
  • 修改 FSM2 包的compil_nc.sh脚本,将模块包含和库路径设置为 Ubuntu 包使用的路径:

     $ diff compil_nc.sh.orig compil_nc.sh
     43,44c43,44
     < $FC -O3 -c -I/usr/lib64/gfortran/modules FSM2_temp.f90
     < $FC -o FSM2 FSM2_temp.o -L/usr/lib64 -lnetcdff
     ---
     > $FC -O3 -c -I/usr/include FSM2_temp.f90
     > $FC -o FSM2 FSM2_temp.o -L/usr/lib/x86_64 -lnetcdff
    

相关内容