微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

netCDF Fortran 编译问题:C 编译器不起作用

如何解决netCDF Fortran 编译问题:C 编译器不起作用


我对 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 的信息以及如何修复它,有人可以解释一下我做错了什么,为什么配置 recap 我的 PC 上没有可用的 C 编译器?

谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。