netcdf-c icon indicating copy to clipboard operation
netcdf-c copied to clipboard

build netcdf with CMAKE under MSVC 2022

Open jbensabat opened this issue 2 years ago • 5 comments

Hello I am trying to build netcdf with cmake under MSVC 2022 first I built hdf5 with zlib

then in CMAKE i get the following error

Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621. CMake Error at C:/software/hdf5/bin/hdf5-config.cmake:145 (include): include could not find requested file:

C:/software/hdf5/cmake/hdf5-targets.cmake

Call Stack (most recent call first): CMakeLists.txt:743 (FIND_PACKAGE)

Using HDF5 include dir: C:/software/hdf5/include; CMake Error at CMakeLists.txt:887 (MESSAGE): HDF5 was built without zlib. Rebuild HDF5 with zlib.

Configuring incomplete, errors occurred! See also "C:/software/netcdf/bin/CMakeFiles/CMakeOutput.log". See also "C:/software/netcdf/bin/CMakeFiles/CMakeError.log".

It seems that the cmake script is not aware of the fact hdf5 was built with zlib

any help would really be appreciated best jac

To report a non-security related issue, please provide:

  • the version of the software with which you are encountering an issue
  • environmental information (i.e. Operating System, compiler info, java version, python version, etc.)
  • a description of the issue with the steps needed to reproduce it

If you have a general question about the software, please view our Suggested Support Process.

jbensabat avatar May 06 '23 15:05 jbensabat

Hi I do not know is this is of interest but I will share it anyway I tried to build netcdf-4.9.2 with hdf-1.12, as the 1.14 version does not seem to create the same directory structure so netcdf cmake can find what it looks for I can then configure the workspace but when I try to build the lib I get numerous errors one of them is that HDF5_OBJID_T is not defined anywhere not in the hdf5 directory neither in the netcdf one. any help would really be appreciated best jac

jbensabat avatar May 10 '23 09:05 jbensabat

Thank you; I'll take a look at this, sorry for the delay in getting back to you! I'm able to build with hdf5-1.10 under Windows, but have not yet tried with newer HDF5 versions.

WardF avatar May 16 '23 17:05 WardF

hi thanks for your reply. I made some progress in the meantime. I was able to compile netcdf-c (downloaded from the github repository) together with hdf-1.12 the netcdf archive that can be downloaded is apparently incomplete hdf-1.12 creates configurration files (hdf-targets,cmake etc) in directories that change from version to version in version 1.12 these were placed in ..\build_CPack_Packages\win64\ZIP\HDF5-1.12.1-win64\share\cmake\hdf5 in version 1.14 this structure has changed and I cold not figure out where the correct files could be placed. I then rolled back to version 1.12 best jac

jbensabat avatar May 17 '23 05:05 jbensabat

I am working to stand up a Windows/Visual Studio dev environment to test on.

WardF avatar May 24 '23 16:05 WardF

@jbensabat, not sure if this is helpful for you, but I thought I'd point out that libnetcdf is available for Windows on Conda-forge, so you can install it with conda/mamba and/or have a look at the Windows build script to see how the Windows build is accomplished there.

zklaus avatar Jul 20 '23 11:07 zklaus