-
Notifications
You must be signed in to change notification settings - Fork 98
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
Official Windows support via CMake #48
Comments
Recently I succeeded in building NetCDF4 on Windows using the MSVC++ and Intel Fortran compilers. The procedure is more or less straightforward, but there is one file that needed patching, netcdf-config.cmake.in. The computation of the prefix path is wrong. Here is the code I use for this: Compute installation prefix relative to this file.get_filename_component (_dir "@CMAKE_CURRENT_LIST_FILE@" PATH) Note that I use CMake's "NMake Makefiles" generator and nmake rather than building via Visual Studio. The latter should not be a problem, but I seldom use that method in conjunction with CMake-based projects. |
That is encouraging to hear, although I didn't realize you could use "NMake Makefiles" with Visual Studio projects. Thanks for the information re: the prefix path, that will be very helpful! |
I tried my best to compile it with Visual studio2010 and Intel Fortran 2013 with CMake,but always failed.Can you give me some instructions or share a x86 lib for win7 with me(for research reason)? My email is 465474307@qq.com,Thank you very much. |
I have used VS 2013 and Intel Fortran 2015 myself. I did create a small batch file to automate things as much as possible, but I also see that it wants either VS 2012 or VS 2013. The reason for that is that the build procedure for HDF5 requires either of these (or else only batch and configuration files for these two environments are provided). What are the symptoms? What messages do you get? |
I eventually succeeded in building netCDF-Fortran with Intel Fortran 17.0 on Windows. Some notes on the process are below. Any advice is appreciated, maybe I could turn this into a pull request. netCDF-C 4.4.1.1 Static LibraryThe Windows distribution for netCDF-C does not include static libraries so you need to build them yourself. I ran CMake with the following arguments, which may vary depending on your HDF5 configuration. If you want to build with a static CRT (/MT) you can also set
netCDF-Fortran 4.4.4 Static LibraryThis is easier than a shared build. I ran CMake with the following arguments. This will build the library only; examples and tests will not build because additional libraries need to be passed to the linker and the current CMake script does not support this. These arguments should disable tests, but since there is no ENABLE_EXAMPLES option in CMakeLists.txt you will need to remove ADD_SUBDIRECTORY(examples) manually for a 'clean' build.
I could then build examples with the following 'one-liner', adjust as necessary for your HDF5 configuration:
netCDF-Fortran 4.4.4 Shared LibraryYou can use the same CMake arguments for the static library but set BUILD_SHARED_LIBS=TRUE and NETCDF_C_LIBRARY to the shared version of the C library, the one provided in the official Windows distribution will work. This will get you almost all the way there, but I had the exact same issues mentioned by @arjenmarkusdeltaresnl in the Intel Forums:
There are two problems here:
My temporary solution was just to remove all of those function calls from netCDF-Fortran because I didn't need them. I think a proper solution would involve either of a couple options:
I'm not sure yet how to resolve the issue with ncerr and ncopts. |
The cmake files for netcdf-fortran need to be overhauled, to leverage some of the knowledge gained whilst enhancing cmake support in netcdf-c. Part of this effort will also be to include official support for netCDF-Fortran using Windows compilers.
We are a bit hobbled by the fact that there aren't any free compilers (I can find) that are commonly used in conjunction with Microsoft Visual Studio. PGI and Intel Fortran Compilers seem to be the main two our community are using. The Intel compiler pricing is prohibitive at this point, but we should be able to get most of the way there using the PGI compilers.
The text was updated successfully, but these errors were encountered: