- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
if I am not in the right forum, I would appreciate if someone would indicate the proper way.
My problem:
I want to install a library to assess data from a certain file format (netCDF), that is, I want to add the ibrary to my Visual Studio installation. I downloaded the latest version of this package from Github. Unfortunately this is source code in a complete directory the size of more than 10 MB in more than 270 files. Amongst the files I spotted two makefiles (Makefile.am and Makefile.im) that I understand should be deployed to do the job. But I never found a hint on how to do this.
Instructions on how to install this packege is rather scarce - and quite unintelligible to me (see here: https://docs.unidata.ucar.edu/netcdf-c/current/building_netcdf_fortran.html).It starts with setting a shell-variable and I have no idea, what that is, leave alone on how to set it to certain values.
So what I would need is a step by step instruction on how to proceed that starts with opening a console window or Visual Studio or whatever is the proper thing to do first and ends up with the library ready to be used in my prog. Does anyone know where to find some such information? "Using makefiles to install libraries into Visual Studio for dummies?'
I am using Visual Studio 2017 in a Windows 11 environment.
Thanks in advance
PF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems that all the instructions you are finding assume Linux and typical tools found there, such as makefiles. Makefiles are build scripts used with the "make" tool. While Visual Studio has a version of this called nmake, it isn't completely compatible.
What one would have to do is study the makefile (there are often many, nested for different parts of the library) and construct VS projects with the source files listed and appropriate compile options. It can be a daunting task.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There seems to be no solution to this problem.
Just for other people, that may face the same issue with files those huge files in netCFD format:
I downloaded a tool to extract data from such a file to excel to save it as a csv-file. I do not know if i can give the link here, for this is payware and I am not aware of this site's policy about advertising. But to Google 'netcfd' and 'Excel' will help.
Cheers
PF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems that all the instructions you are finding assume Linux and typical tools found there, such as makefiles. Makefiles are build scripts used with the "make" tool. While Visual Studio has a version of this called nmake, it isn't completely compatible.
What one would have to do is study the makefile (there are often many, nested for different parts of the library) and construct VS projects with the source files listed and appropriate compile options. It can be a daunting task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are using LINUX, follow the instructions on that page, after you follow the instructions to install the C version, if you are using Windows, install the Linux system on Windows and then follow the LINUX instructions, the chances you will get a MSVS running are not good, ie do not waste good time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, this does not sound convincing either. So I am happy with my approach to buy some tool.
Thanks
PF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your comment Steve.
This Makefile here has more than 1000 lines. And I do not understand the statements at all. So this task would be hopeless.
So I think my pragmatic approach - and the expenditure of a small sum of money - were justified.
PF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good choice, life is to short for this type of nightmare.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Often, as suggested, it is too much effort to get libraries supplied as source code to build under Windows. However, in this case it's not too painful. Below is the step-by-step procedure I used to build the fortran library and run the first F77 and F90 examples - not neccessarily the correct or best method but it's what I ended up doing.
I'm running Windows 10 with Visual Studio Community 2017 Version 15.9.52, Intel Fortran Compiler – toolkit version: 2022.3.0 (Intel Fortran Compiler Classic 2021.7.0) installed.
Download CMake Windows x64 Installer cmake-3.25.2-windows-x86_64.msi from https://cmake.org/download/
Download netCDF-3 64-bit Windows binary netCDF4.9.1-NC3-64.exe from https://downloads.unidata.ucar.edu/netcdf/
Download netcdf-fortran-main.zip from https://github.com/Unidata/netcdf-fortran (https://codeload.github.com/Unidata/netcdf-fortran/zip/refs/heads/main)
(I couldn't get netcdf-fortran-4.6.0.zip from https://downloads.unidata.ucar.edu/netcdf/ to work as some source files seemed to be missing.)
Install CMake
Install netCDF-3 libraries
Do not add netCDF to the system PATH (could add it. I didn't but then needed to make sure the applications could see it.)
(Leave Create netCDF Desktop Icon unchecked)
Destination folder G:\netCDF\netCDF 4.9.1 (for the sake of example netCDF is installed in G:\netCDF)
Install all components
Extract all files netcdf-fortran-main.zip to G:\netCDF (the folder netcdf-fortran-main is contained in the zip file and is extracted to G:\netCDF)
Run CMake
Where is the source code: G:/netCDF/netcdf-fortran-main
Where to build the binaries: G:/netCDF/netcdf-fortran-main/MyBuild
Press Configure
Specify the generator for this project: Visual Studio 15 2017
Optional platform for generator: x64
Use default native compilers
will fail: set NETCDF_C_LIBRARY to G:/netCDF/netCDF 4.9.1/lib/netcdf.lib
set NETCDF_C_INCLUDE_DIR to G:/netCDF/netCDF 4.9.1/
(might have to Configure twice to set both of the above)
Press Configure
(will produce a number of not found messages in red but will end with "Configuring done" in output window)
Press Generate
(short display of progress dialog followed by "Generating done" in output window)
Close CMake
Go to folder G:\netCDF\netcdf-fortran-main\MyBuild
Open NC4F.sln in Visual Studio
Build netcdff (IFORT) (or check dependencies of netcdff and build ZERO_CHECK and/or netcdff_c)
There will be compilation errors. To fix:
in module_netcdf_nc_data.F90 insert
#else
Integer(C_INT), Parameter :: NC_ENOPAR = -114
Integer(C_INT), Parameter :: NC_NOQUANTIZE = 0
Integer(C_INT), Parameter :: NC_QUANTIZE_BITGROOM = 1
above the #endif at the end of the module
netcdff (IFORT) is a dynamic library project. Unfortunately nothing is exported and there is no def file. Easiest fix is to make the project a static library. (Unless there is a simple way of exporting everything. If there is I'm not aware of it.)
Close Visual Studio.
Edit netcdff.vfproj in G:\netCDF\netcdf-fortran-main\MyBuild\fortran
Replace all occurrences of 'Dynamic' with 'Static' and all occurrences of '<Tool Name="VFManifestTool"/>' with '' (do not include single quotes)
Open NC4F.sln in Visual Studio
Build netcdff
Build and run F77_tests_pres_temp_4D_wr followed by F77_tests_pres_temp_4D_rd
Build and run F90_tests_pres_temp_4D_wr followed by F90_tests_pres_temp_4D_rd
(If netcdf.dll is not in the path, add path=G:\netCDF\netCDF 4.9.1\bin to the Environment item of the Debugging tab of the projects' properties.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, mfinnis,
finally I gave it a try - but got stuck.
The configuration did not finalize with 'Configuring done' but with 'Error in configuration process, .project files may be invalid.'
I followed your advice step by step with only slight modifications:
I could not pinpoint cmake-3.25.2-windows-x86_64.msi instead but downloaded cmake-3.25.3-windows-x86_64.msi instead.
I changed the location from G:/... to C:/... but took care to carry this through all your instructions.
I modified the settings after the failed configuration processes (Resetting NETCDF_C_LIBRARY and NETCDF_C_INCLUDE_DIR.
There seem to be more items with a 'not found' tag in the settings of CMake. See Image:
Any Idea what went wrong?
I am using Visual Studio Community 2017 (Version 15.9.51) in a Windows 11 environment.
Cheers and thanks for your support
PF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The only difference I have in the CMake window is that I don't have TEST_WITH_VALGRIND checked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks again.
This check was set automatically. I removed it but this was of no conseqquence.
One of the messages in this output window gave the information that 'netcfd_meta.h' was not found. I could spot it and copied the file to the netcdf 4.9.1 directory and the configuration and build processes yielded this 'done'-message for configuration and creation.
In VS however I got stuck again. After the addition of these four lines of code to module_netcdf_nc_data.F90 the build of netcdff (IFORT) failed for netcdf.h could not be found. ('No such file or directory'). I spotted this file in c:\netcdf\netcdf 4.9.1\include and added this to the include-path in the project settings - even if c:\netcdf\netcdf 4.9.1 was present already.
Then I copied it to netcdf 4.9.1 directory and the build went well.
Building netcdff (IFORT) I got the error-message, that 'netcfd.h' could not be found. I spotted it in the include. folder, copied it to the netcdf 4.9.1 directory and the build completed successfully.
Now I want to edit netcdff.vfproj but there seems some text missing in your guide:
>Replace all occurrences of ... '<Tool Name="VFManifestTool"/>' with '' (do not include single quotes)<
I am at a loss what to put in in place of <Tool Name="VFManifestTool"/>
Cheers
PF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Absolutly nothing, ie ensure the replace string is empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, looking at the CMake options, unchecking the BUILD_SHARED_LIBS will generate a static library project for netcdff so that netcdff.vfproj doesn't need editing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay.
My installation did not like the modification to nothing. I received error-messages that some name is starting with an illegal character. So I did the build once again. That is, I deleted 'MyBuild' and started all over again.
BTW: for NETCDF_C_INCLUDE_DIR I specified G:/netCDF/netCDF 4.9.1/include instead of ... /netCDF 4.9.1/ alone and the build continued without error. That is, some errormessages occurred but the 'configuration done' and 'creatian done' messages were reached without adding the four lines of code to module_netcdf_nc_data.F90.
I could build netcdff without error, but the test programs seem not to find the library. And I am at a loss on where to specify the additional path to netcdff.lib which I spotted in ...\MyBuild\Fortran\Debug.
Cheers
PF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(I too deleted MyBuild and started again. I had missed off the \include in the steps above - not sure how as it must have been there when I ran CMake.)
The test projects generated on my system have under the project properties, Configuration Properties | Linker | Input | Additional Dependencies
$(NOINHERIT) user32.lib ..\..\fortran\Debug\netcdff.lib "G:\netCDF\netCDF 4.9.1\lib\netcdf.lib" "G:\netCDF\netCDF 4.9.1\lib\netcdf.lib"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Same for me.
But I get this errormessage when building the test program (see image).
I am using the German version. The first two errormessages translate to something like 'unresolved global symbols' but this occurs when compilation of the routines failed.
The next, the blue one and all the following is something like 'reference to an undissolved global symbol ...'
from these I get about two dozen so it seems to me that something general is wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried building the other examples eg F77_tests_pres_temp_4D_rd?
I've done nothing else (other than clearing BUILD_SHARED_LIBS in CMake and as a consequence not editing netcdff.vfproj ) and have no problem building all the projects in the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, I tried f90_tests_pres_temp_4D_rd. But with tha same result.
I am running out of time for today but tomorrow I will give it a new try with a new build.
Have a nice weekend (or what is left)
PF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow, mfinnis, thanks for your comprehensive response.
I will give it a try the next days and report here.
Cheers
PF
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page