This simple note describes how one can build HDF4 to CF conversion toolkit with MS Visual studio on windows.
The work is under experimental stage. This note aims for users who have some windows MS Visual studio IDE experience.
We successfully build static library and utilities and 
test(limited to only our own testsuite) under Visual Studio 2010 on windows 7. 
For HDF4/HDF-EOS2 to netCDF/CF utility binaries on windows, please check http://hdfeos.org/software/h4cflib/bin/windows.

I. Preconditions

H4CF conversion toolkit depends on a few external libraries. The external libraries are

HDF4 and the dependent zlib and jpeg libraries: 
    libhdf.lib, libmfhdf.lib, libxdr.lib, libzlib.lib,libjpeg.lib

HDF-EOS2 libraries: 
    hdfeos.lib and gctp.lib

To build the HDF4 to netCDF-3/CF utility, netCDF-3 library is needed.
	netcdf.lib 

To build HDF4 to netCDF-4/CF utility, netCDF-4 and HDF5 libraries are needed.
    netcdf.lib, libhdf5.lib, libhdf5_hl.lib
	
Additionally, if you want to use the szlip compression, szip library is needed to build HDF4 and HDF5 libraries.
The template project and solution files in this note assume that the szip compression is NOT used. 

Note:
1. To build static HDF4 to netCDF/CF libraries and utilities, all the dependent libraries need to be built statically to
avoid the mixing of static and dynamic libraries linking error(LINK2005).

2. HDF4 libraries must be built with --disable-netCDF option, otherwise, the redefined symbols of linking errors will be occured for netCDF APIs.
To build HDF4 libraries with the --disable-netCDF option, one must change the included header file netcdf.h to hdf2netcdf.h if
netcdf.h still exists in the HDF4 included directory. H5pubconf.h also needs to be changed properly. Cmake users can try cmake options to see if
the build is simplified.

II. How to build the conversion toolkit with Visual Studio

1. From the top directory of the source tree, cd to windows/h4cflib, open h4cflib.sln with Visual Studio.
   You should see three project files, h4cflib, h4tonccf3 and h4tonccf4.
   
   The paths of dependent libraries and headers should be changed.  Details are as follows.
   
2. To build the HDF4 to CF conversion library, choose project h4cflib, then go to "configuration properties",
   then click "VC++ Directories" under the menu,
   replace the filled path with the path of HDF4 and HDF-EOS2 headers at your system. Click OK at the property setting page. 
   Then right click the project h4cflib, choose Build. h4cflib.lib can be built. 
   
3. To build the HDF4 to netCDF3/CF conversion tool, choose project h4tonccf3, then go to "configuration properties",
   then click "C/C++" under the menu, replace the filled path with the path of HDF4 and HDF-EOS2 headers at your system.
   Then choose "Linker" under the menu, select "Input" and replace the filled path(must include the library names)
   with the path of dependent libraries at your system. These libraries are listed in Preconditions. Note HDF5 libraries 
   are not needed to build the HDF4 to netCDF3/CF conversion tool. After setting all these paths, 
   click OK at the property setting page. then right click the project h4tonccf3, choose Build, h4tonccf3 can be built.
      
4. To build the HDF4 to netCDF4/CF conversion tool, choose project h4tonccf4, then go to "configuration properties",
   then click "C/C++" under the menu, replace the filled path with the path of HDF4 and HDF-EOS2 headers at your system.
   Then choose "Linker" under the menu, select "Input" and replace the filled path(must include the library names) 
   with the path of dependent libraries at your system. These libraries are listed in Preconditions. 
   Note HDF5 libraries must be present to build the HDF4 to netCDF4/CF conversion tool. After setting all these paths, 
   click OK at the property setting page. then right click the project h4tonccf4, choose Build, h4tonccf4 can be built.

If all are built successfully, you should find the following library and executables under either 
windows/h4cflib/Debug or windows/h4cflib/Release 

h4cflib.lib
h4tonccf3.exe( convert to netCDF3)
h4tonccf4.exe( convert to netCDF4)

III. How to test the conversion utility

We provide two batch files ncdumptest.bat and ncdump4test.bat on how to test the conversion utility h4tonccf3 and h4tonccf4. 
These batch files are designed to be simple and they are under windows/bin. Several manual operations are expected from the users. 

0. Make sure that ncdump.exe from Unidata can be run under windows/bin. 
   To test h4tonccf3.exe, netCDF3' ncdump.exe should be used. To test h4tonccf4.exe, netCDF4's ncdump.exe should be used.
   
1. Copy h4tonccf3.exe or h4tonccf4.exe to windows/bin.
2. To test h4tonccf3.exe, run ncdumptest.bat>ncdumptest.out 2>&1 
3. To test h4tonccf4.exe, run nc4dumptest.bat >nc4dumptest.out 2>&1


Check ncdumptest.out or nc4dumptest.out, 
you may see lines like "Done with writing netcdf file etc.", you can ignore those files.
Further down, you may see lines like 
"Comparing files C:\..... and ...."  and then 
"FC: no differences encountered."

These messages show that particualar test gets passed.

For some tests, you may see something like the following or the similar:
<<<<
Comparing files C:\USERS\YMUQUN\DESKTOP\H4CFLIB-TEST\H4CFLIB\TESTSUITE\NC\testvs4.hdf.nc.cdl and TESTVS4.NC.CDL.OUT
***** C:\USERS\YMUQUN\DESKTOP\H4CFLIB-TEST\H4CFLIB\TESTSUITE\NC\testvs4.hdf.nc.cdl
        float vdata_Vdata_DFNT_FLOAT32_vdf_Field_DFNT_FLOAT32(VDFDim0_vdata_Vdata_DFNT_FLOAT32_vdf_Field_DFNT_FLOAT32) ;
                vdata_Vdata_DFNT_FLOAT32_vdf_Field_DFNT_FLOAT32:FieldAttr_DFNT_FLOAT32 = 0.f, 1.f, -1.f, 3.402823e+38f, 1.17549
4e-38f, -3.402823e+38f, -1.175494e-38f ;
                vdata_Vdata_DFNT_FLOAT32_vdf_Field_DFNT_FLOAT32:origname = "Field_DFNT_FLOAT32" ;
***** TESTVS4.NC.CDL.OUT
        float vdata_Vdata_DFNT_FLOAT32_vdf_Field_DFNT_FLOAT32(VDFDim0_vdata_Vdata_DFNT_FLOAT32_vdf_Field_DFNT_FLOAT32) ;
                vdata_Vdata_DFNT_FLOAT32_vdf_Field_DFNT_FLOAT32:FieldAttr_DFNT_FLOAT32 = 0.f, 1.f, -1.f, 3.402823e+038f, 1.1754
94e-038f, -3.402823e+038f, -1.175494e-038f ;
                vdata_Vdata_DFNT_FLOAT32_vdf_Field_DFNT_FLOAT32:origname = "Field_DFNT_FLOAT32" ;
				
>>>>

These differences can be ignored. They are due to different representations of some numbers.



				