New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NetCDF Library Linkage on Windows Using CMake #2533
Comments
For a start, you should go to this page:
https://downloads.unidata.ucar.edu/netcdf/
and then you should download and install either
netCDF4.9.0-NC4-DAP-32.exe
<https://downloads.unidata.ucar.edu/netcdf-c/4.9.0/netCDF4.9.0-NC3-DAP-32.exe>
or
netCDF4.9.0-NC4-DAP-64.exe
<https://downloads.unidata.ucar.edu/netcdf-c/4.9.0/netCDF4.9.0-NC3-DAP-32.exe>
Depending on if your machine is 64 bit (most likely) or 32 bit.
Then try running your cmake script again.
…On 10/21/2022 10:58 AM, skstr3182 wrote:
NetCDF Version: netCDF-C 4.9.0 (2022-06-10, the latest for now)
IDE: Visual Studio 2022
CMake Version: 3.24.1
Compiler: MSVC++ and nvcc
Hello.
I'm not sure it is proper to upload my question here, so please tell
me where to ask if the question is not related to here.
My issue is configuring and compiling a program which involves NetCDF
as a third-party library.
CMake itself does not generate a problem, but building the program has
a issue. ("cmake --build ." or MSVC builder)
The error message from the linker says it cannot open the input
library files:
* hdf5-shared
* hdf5_hl-shared
* C:/share/VS15/x64/lib/zlib.lib
* C:/share/VS15/x64/lib/libcurl_imp.lib
For flexible compilation, I'm using CMake, but NetCDF does not provide
"FindNetCDF.cmake" for "find_package(NetCDF)" command in CMake.
Therefore, I googled and found a custom "FindNetCDF.cmake" from VTK:
https://gitlab.kitware.com/vtk/vtk/-/blob/master/CMake/FindNetCDF.cmake
<url>
and used this as:
|target_link_libraries(my_project INTERFACE NetCDF::NetCDF)|
In the FindNetCDF script, it calls |find_package(netCDF CONFIG
QUIET)|, and I assumed this instruction invokes the script provided by
the NetCDF team, *"C:\Program Files\netCDF
4.9.0\lib\cmake\netCDF\netCDFConfig.cmake"*
And in the *"netCDFConfig.cmake"* file, it includes
*"netCDFTargets.cmake"* which is located at the same directory.
The problem is here, which lies at line 56 and says:
|set_target_properties(netCDF::netcdf PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
"${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES
"hdf5-shared;hdf5_hl-shared;C:/share/VS15/x64/lib/zlib.lib;C:/share/VS15/x64/lib/libcurl_imp.lib"
)|
When I build the project, the four libraries written after
"INTERFACE_LINK_LIBRARIES" cause the linker error.
*Those libraries literally do not exist.*
So, my question is, is there any alternative to still utilize CMake's
find_package feature in linking my project to NetCDF?
Since I pursue cross-compile feature, I want to use CMake for my project.
Thanks in advance.
Screenshot_1
<https://user-images.githubusercontent.com/43165321/197247705-cc9e27c7-20a7-4b0d-a4a4-e976e9910b84.png>
—
Reply to this email directly, view it on GitHub
<#2533>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG47W6PZ5NQ4CHPTVF5B7TWELDTVANCNFSM6AAAAAARLLBT2I>.
You are receiving this because you are subscribed to this
thread.Message ID: ***@***.***>
|
Dear @DennisHeimbigner I exactly followed what you said. |
I am not an expert in cmake, so I will have to turn this over to someone |
Thanks for your support. I have not posted anything to the mailing list. |
NetCDF Version: netCDF-C 4.9.0 (2022-06-10, the latest for now)
IDE: Visual Studio 2022
CMake Version: 3.24.1
Compiler: MSVC++ and nvcc
Hello.
I'm not sure it is proper to upload my question here, so please tell me where to ask if the question is not related to here.
My issue is configuring and compiling a program which involves NetCDF as a third-party library.
CMake itself does not generate a problem, but building the program has a issue. ("cmake --build ." or MSVC builder)
The error message from the linker says it cannot open the input library files:
For flexible compilation, I'm using CMake, but NetCDF does not provide "FindNetCDF.cmake" for "find_package(NetCDF)" command in CMake.
Therefore, I googled and found a custom "FindNetCDF.cmake" from VTK:
https://gitlab.kitware.com/vtk/vtk/-/blob/master/CMake/FindNetCDF.cmake
and used this as:
target_link_libraries(my_project INTERFACE NetCDF::NetCDF)
In the FindNetCDF script, it calls
find_package(netCDF CONFIG QUIET)
, and I assumed this instruction invokes the script provided by the NetCDF team, "C:\Program Files\netCDF 4.9.0\lib\cmake\netCDF\netCDFConfig.cmake"And in the "netCDFConfig.cmake" file, it includes "netCDFTargets.cmake" which is located at the same directory.
The problem is here, which lies at line 56 and says:
set_target_properties(netCDF::netcdf PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include" INTERFACE_LINK_LIBRARIES "hdf5-shared;hdf5_hl-shared;C:/share/VS15/x64/lib/zlib.lib;C:/share/VS15/x64/lib/libcurl_imp.lib" )
When I build the project, the four libraries written after "INTERFACE_LINK_LIBRARIES" cause the linker error.
Those libraries literally do not exist.
So, my question is, is there any alternative to still utilize CMake's find_package feature in linking my project to NetCDF?
Since I pursue cross-compile feature, I want to use CMake for my project.
Thanks in advance.
The text was updated successfully, but these errors were encountered: