I have a problem with netCDF Fortran compilation. Here is the output of my compilation:
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.
Here is my compilation script:
#!/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
It also should be noted that if I comment the strings providing LDFLAGS, CPPFLAGS and LIBS, compilation will go another understandable way (I cut the output for more convenient view):
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.
Here is the output of 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
Can someone please explain me what I've done wrong and why configure recap there is no working C compilers on my PC if I provide an information about netCDF-C and how to fix it?
Thank you!