Could NOT find NETCDF (missing: NETCDF_LIBRARY HAVE_NETCDF4)

All,

**

I could not be able to install GMT6.1 due to missing NETCDF LIBRARY. Here are the errors after running (see below the details)

**

cmake …

CMake version: 3.13.3
– The C compiler identification is GNU 8.2.0
– Check for working C compiler: /opt/apps/resif/data/production/v1.2-20191021/default/software/compiler/GCCcore/8.2.0/bin/cc
– Check for working C compiler: /opt/apps/resif/data/production/v1.2-20191021/default/software/compiler/GCCcore/8.2.0/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
CMake Warning at src/CMakeLists.txt:90 (message):

  • Cannot find GraphicsMagick program gm - gmt movie will be unable to make*
  • animated GIFs*

– Searching dependent libraries. This may take a few minutes…
CMake Error at /mnt/irisgpfs/apps/resif/data/production/v1.2-20191021/default/software/devel/CMake/3.13.3-GCCcore-8.2.0/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):

  • Could NOT find NETCDF (missing: NETCDF_LIBRARY HAVE_NETCDF4)*
    Call Stack (most recent call first):
  • /mnt/irisgpfs/apps/resif/data/production/v1.2-20191021/default/software/devel/CMake/3.13.3-GCCcore-8.2.0/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)*
  • cmake/modules/FindNETCDF.cmake:136 (find_package_handle_standard_args)*
  • src/CMakeLists.txt:138 (find_package)*

– Configuring incomplete, errors occurred!

However, all the necessary Library pointer to NETCDF is in fact available in nc-config: See below:

prefix=“/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a”
exec_prefix=“/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a”
libdir=“/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/lib64”
includedir=“/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/include”

cc=“/opt/apps/resif/data/production/v1.2-20191021/default/software/mpi/OpenMPI/3.1.4-GCC-8.2.0-2.31.1/bin/mpicc”
cflags=“-I/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/include”
libs=“-L/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/lib64 -lnetcdf -lhdf5_hl -lhdf5 -lsz -lz -ldl -lm -lpthread -lcurl”

PS. my netCDF is available with mpi enabled.

Over the years, we have had various flavor of these install errors, often related with HAVE_NETCDF4 or netcdf_deflate. I think in most/all cases it came down to the user having more than one set netcdf library and include files installed on their system, and cmake somehow gets the wrong one. Please check your entire disks for other libnetcdf.* files first. The search for libraries is a cmake thing, not GMT. All we do in CMakelists.txt is this:

# NetCDF is required
find_package (NETCDF REQUIRED)
include_directories (${NETCDF_INCLUDE_DIR})

Dear Paul, thank for your response. I have spent a good part of the afternoon to sort out this NETCDF issues but still have not succeeded.
In the system that I have no control over, I found three directories where the libnetcdf* files are found:

1. …/netCDF-Fortran/4.4.5-iimpi-2019a/lib
2. …/netCDF/4.6.2-iimpi-2019a/lib64
3. …/netCDF/4.6.2-gompi-2019a/lib64

So I make a decsion to choose using set NETCDF_ROOT command in the ConfigUser.cmake to decide which NETCDF directory cmake should take:

This what my CMakeCache.txt shows:

//Path to a program.
NETCDF_CONFIG:FILEPATH=…/netCDF/4.6.2-gompi-2019a/bin/nc-config
//Path to a file.
NETCDF_INCLUDE_DIR:PATH=…/netCDF/4.6.2-gompi-2019a/include
//Path to a library.
NETCDF_LIBRARY:FILEPATH=…/netCDF/4.6.2-gompi-2019a/lib64/libnetcdf.so

As I said, I have no control over to delete the other installed libraries but the error still remains the same, i.e. Could NOT find NETCDF (missing: NETCDF_LIBRARY HAVE_NETCDF4)

Any further comments, please?

/Yacob

On Windows (never mind all those variables needed for my setting) I have this

	# set location of netcdf (can be root directory, path to header file or path to nc-config):
	set(NETCDF_DIR "${DEPS_ROOT}/netcdf_GIT/${COMP_SUBDIR}/${VC}_${BITAGE}")
	set(NETCDF_LIBRARY "${DEPS_ROOT}/netcdf_GIT/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/netcdf.lib")

try to adapt this for your case

Thank you, Joaquim

I did as you have recommended as: (I hope it is correct, see below) but it did not solve

> set (NETCDF_DIR  ../netCDF/4.6.2-gompi-2019a)
> set (NETCDF_LIBRARY ../netCDF/4.6.2-gompi-2019a/lib64/libnetcdf.so)

However, during cmake … stage, before I made the changes as per recommendations above CmakeCache.txt file seems to have already picked the correct directory structure, see below:

//Path to a program.
NETCDF_CONFIG:FILEPATH=…/netCDF/4.6.2-gompi-2019a/bin/nc-config
//Path to a file.
NETCDF_INCLUDE_DIR:PATH=…/netCDF/4.6.2-gompi-2019a/include
//Path to a library.
NETCDF_LIBRARY:FILEPATH=…/netCDF/4.6.2-gompi-2019a/lib64/libnetcdf.so

I guess you are right. The recipe above would serve to direct it to another netCDF lib since, for whatever reason, that one does not please the cmake. opmpi stands for openMPI. Can it be that there are missing dependencies at the time of the testing?

Yes, Jaoquim, I am aware of it. The netCDF is enabled with openMPI. I do not see any dependencies that may be lacking. The error remain the same with no further explanations. It is exhausting.

Yes, every time I touch unix it consumes me days of work. That’s why I keep away from it the furthest I can. :sweat:

Was that netCDF built with HDF5 support? Because netcdf4 needs HDF5.

Yes it is built with HDF5 library. Is it possible to force ConfigUser.cmake file to select where my hdf5 library is?

No, GMT does not depend directly on HDF only indirectly via netCDF (and GDAL)

Thanks, Joaquim for the follow-up.

my libnetcdf.settings shows where the correct library of hdf5 is liked to.

#Compiling Options of netCDF

-L…/HDF5/1.10.5-gompi-2019a/lib

However, my CMakeCache.txt during cmake … shows that the hdf5 is not found, see below:

//Path to a library.
_found_lib_hdf5:FILEPATH=_found_lib_hdf5-NOTFOUND
//Path to a library.
_found_lib_hdf5_hl:FILEPATH=_found_lib_hdf5_hl-NOTFOUND

Have a look at the forensics done for a similar problem last year on GitHub. See what you can find out about your installation.

Thanks Paul, in the mean time this is what I have so far:

  > --cc            -> /opt/apps/resif/data/production/v1.2-20191021/default/software/mpi/OpenMPI/3.1.4-GCC-8.2.0-2.31.1/bin/mpicc
>   --cflags        -> -I/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/include
>   --libs          -> -L/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/lib64 -lnetcdf -lhdf5_hl -lhdf5 -lsz -lz -ldl -lm -lpthread -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   -> no
>   --has-szlib     -> no
>   --has-cdf5      -> yes
>   --has-parallel4 -> yes
>   --has-parallel  -> yes
> 
>   --prefix        -> /opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a
>   --includedir    -> /opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/include
>   --libdir        -> /opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/lib64
>   --version       -> netCDF 4.6.2

And is nc_def_var_deflate one of the symbols in the library .so file?

nm -D /usr/lib/x86_64-linux-gnu/libnetcdf.so.13 | grep nc_def_var_deflate
0000000000022170 T nc_def_var_deflate

grep nc_def_var_deflate netcdf.h

  • property can be set with the function nc_def_var_deflate(). */
    nc_def_var_deflate(int ncid, int varid, int shuffle, int deflate,

Neverthless, I have two instance of netcdf.h

./netCDF/4.6.2-iimpi-2019a/include/netcdf.h
./netCDF/4.6.2-gompi-2019a/include/netcdf.h

I have no control over the two instances of netcdf.h file.

Maybe look for clues in the cmake error logs inside the build directory

find . -name '*.log’

./CMakeFiles/CMakeOutput.log

./CMakeFiles/CMakeError.log

Nothing to report from ./CMakeFiles/CMakeOutput.log that looks suspicious at least to me. I can send the whole content if needed.

I am sorry that this is so complicated for you. Please wipe your build directory and start from cmake again, and once it ends please post the terminal output from cmake plus any *.log files created in the build directory as files here, and we will have a look to see if we can figure out what is being rejected.

These are the files and terminal output.
CMake.zip (8.9 KB)

CMake version: 3.13.3
– The C compiler identification is GNU 8.2.0
– Check for working C compiler: /opt/apps/resif/data/production/v1.2-20191021/default/software/compiler/GCCcore/8.2.0/bin/cc
– Check for working C compiler: /opt/apps/resif/data/production/v1.2-20191021/default/software/compiler/GCCcore/8.2.0/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Found UnixCommands: /usr/bin/bash
– Found Git: /usr/bin/git (found version “1.8.3.1”)
CMake Warning at src/CMakeLists.txt:90 (message):
Cannot find GraphicsMagick program gm - gmt movie will be unable to make
animated GIFs

– Searching dependent libraries. This may take a few minutes…
CMake Error at …/CMake/3.13.3-GCCcore-8.2.0/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find NETCDF (missing: NETCDF_LIBRARY HAVE_NETCDF4)
Call Stack (most recent call first):
…/CMake/3.13.3-GCCcore-8.2.0/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindNETCDF.cmake:137 (find_package_handle_standard_args)
src/CMakeLists.txt:138 (find_package)

– Configuring incomplete, errors occurred!

What I can tell from terminal outout and your logs is this:

  1. cmake is unable to find the netcdf library. That is the main output message.
  2. The Cache shows it found the nc-config script and the netcdf include dir but the library path is not to be found
  3. The log lists more libraries than there are people in Hawaii (compared to what I see in my log) but there is not a trace of netcdf. So the check for nc_def_var_deflate is never run since no library was found.
  4. I think earlier you entered specific paths to the ConfigUser.cmake file and then the Cache file had a NETCDF_LIBRARY entry. Did that lead to a check for nc_def_var_deflate in the log?
  5. Per the cmake/modules/FindNETCDF.cmake file, you can set NETCDF_DIR or NETCDF_ROOT in the environment to specify the location of NetCDF. Try to set
    export NETCDF_ROOT=/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a before running cmake.