Unidata / netcdf-cxx4

Official GitHub repository for netCDF-C++ libraries and utilities.
Other
124 stars 49 forks source link

NetCDF-C++: Build on Windows 10 x64 #77

Open nyckmaia opened 4 years ago

nyckmaia commented 4 years ago

Hi,

I already downloaded binary NetCDF-C installer (called netCDF4.7.1-NC4-DAP-64.exe) from the offical website (link here) installed it and add the installed folder to my PATH. So I tested it in the Windows console runing: ncdump.exe...and all works good!

Now I cloned the NetCDF-CXX4 repository and tried to compile it, but I got a lot of CMake errors.

My system is: Windows 10 x64 Visual Studio 2019 Enterprise CMake 3.14.4 NetCDF-CXX 4.3.1

What I did: Inside the cloned NetCDF-CXX4 folder, I created a folder called "build". Inside the build folder I typed: cmake ..

Here is the console error:

 cmake ..
-- Building for: Visual Studio 16 2019
-- The C compiler identification is MSVC 19.23.28105.4
-- The CXX compiler identification is MSVC 19.23.28105.4
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found bash: C:/Program Files/Git/usr/bin/bash.exe
-- Looking for nc_use_parallel_enabled in netcdf
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
  Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at C:/Program Files/cmake/share/cmake-3.14/Modules/CheckLibraryExists.cmake:67 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  CMakeLists.txt:382 (CHECK_LIBRARY_EXISTS)

-- Configuring incomplete, errors occurred!
See also "C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeOutput.log".

What I have to do to build the NetCDF-CXX4 static/dynamic libraries in my system?

WardF commented 4 years ago

When you run cmake .., you will need to specify the HDF5_DIR location. For example, on my system, I have to invoke the following:

$ cmake .. -DCMAKE_PREFIX_PATH=[path to netcdf install] -DHDF5_DIR=[path to netcdf install]/cmake/hdf5 

I will get our instructions updated, but in the meantime, does this help?

nyckmaia commented 4 years ago

Thank you @WardF ...

My command now is this below, but I got the same error messages:

cmake .. -DCMAKE_PREFIX_PATH="C:\Program Files\netCDF 4.7.1" -DHDF5_DIR="C:\Program Files\netCDF 4.7.1\lib\cmake\hdf5"

NetCDF

The NetCDF is installed here: C:\Program Files\netCDF 4.7.1 Inside this folder I have 3 folders:

Inside lib I have:

HDF5 C

The HDF5 C library is installed here: C:\Program Files\HDF_Group\HDF5\1.10.5 Inside this folder I have:

So, could you help me to write the cmake .. command?

WardF commented 4 years ago

Drop the 'lib' in the -HDF5_DIR, use -DHDF5_DIR=C:\Program Files\ netCDF 4.7.1\cmake\hdf5. Does that give you the same error? I'm also unsure if you need to escape the spaces from the Windows command line. Try it without and let me know if that works.

nyckmaia commented 4 years ago

Yes, I tried it: cmake .. -DCMAKE_PREFIX_PATH="C:\Program Files\netCDF 4.7.1" -DHDF5_DIR="C:\Program Files\netCDF 4.7.1\cmake\hdf5"

But if you look my folder structure in my post above, the cmake folder is inside the lib folder. So I can't remove the lib in the path....but I tried too like this last command above.

Yes,, I got the same error messages.

About "escape spaces", I'm putting all path inside the " ". I tried to use "double back slashes" (\\) , but it doesn't work too.

Is there another thing to try?

DennisHeimbigner commented 4 years ago

What shell are you using? e.g. windows cmd, window powershell, ?

nyckmaia commented 4 years ago

I tried in 2 shells, and I got the same error on both:

doedsjarl666 commented 4 years ago

The issue is in find_package() usage. I would recommend setting HDF5_DIR as an environmental variable and look at issue#88, that will help.

srihegde commented 8 months ago

For adding a file path with spaces I followed this link. Seems to work for Powershell