title: getting stared with HDF5 on Visual Studio 2013 with Visual C++ 2013
body: <p>I am having a hard time getting an HDF5 example working with Visual Studio 2013 (C++).
  The example is at: <a href="http://www.hdfgroup.org/ftp/HDF5/examples/misc-examples/stratt.cpp" rel="nofollow">http://www.hdfgroup.org/ftp/HDF5/examples/misc-examples/stratt.cpp</a> and I've posted the code below for completeness.  </p>
  
  <p>My first question is:  Will the latest HDF5 (version 1.8.13) work with Visual C++ 2013?  The docs only mention 2012 that I can see, but generally I've had no problems using 2013 where 2012 is mentioned.</p>
  
  <p>I tried the example program as both a 32 bit and a 64 bit app.  Ultimately, I'm interested in 64 bit.  In the project settings for 32 bit, under VC++ settings, I added to the include directories: C:\Program Files (x86)\HDF_Group\HDF5\1.8.13\include
  To the library directories, I added: C:\Program Files (x86)\HDF_Group\HDF5\1.8.13\lib</p>
  
  <p>To the Linker->Input, I added: hdf5.lib;hdf5_cpp.lib
  When I ran, I (not unexpectedly) got the message, "The program can't start because hdf5.dll is missing from your computer..." 
  So to the debug directory, I added, hdf5.dll and hdf5_cpp.dll from the directory:
  C:\Program Files (x86)\HDF_Group\HDF5\1.8.13\bin</p>
  
  <p>I then get the runtime error:</p>
  
  <p>The application was unable to start correctly (0xc000007b).  Click OK to close the application.  Any ideas?</p>
  
  <p>Incidentally, when I tried the x64 bit version (using the 64 bit setttings, directories and files), I got slightly different errors.  The program runs to the end, but no attribute is written to the console, no file is produced, and I get the dreaded error at the end (after hitting f10 on the last line):</p>
  
  <p>Unhandled exception at 0x000007FEF05E512D (msvcp120d.dll) in HDF5AttributeExample2.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.</p>
  
  <p>In both cases (32 and 64 bit) my gut tells me that I have some sort of configuration problem (wrong lib, wrong setup, etc.)  I'd really appreciate any help or suggestions folks can offer.</p>
  
  <p>If there is another Visual C++ HDF5 example, by all means please tell me!</p>
  
  <p>Thanks,</p>
  
  <p>Dave</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  
  #include "H5Cpp.h"
  
  using std::cout;
  using std::endl;
  
  using namespace H5;
  
  const H5std_string FILE_NAME("string_test.h5");
   const H5std_string DS_NAME("Data Set 1");
  const H5std_string ATTR_NAME("String Attribute");
  
  int main(void) {
  
  // Create the named file
  H5File file = H5File(FILE_NAME, H5F_ACC_TRUNC);
  
  // Create new dataspace for the dataset
  const int rank = 3;
  const int dim1 = 2;
  const int dim2 = 2;
  const int dim3 = 2;
  hsize_t  dims[rank] = { dim1, dim2, dim3 };
  DataSpace dataspace = DataSpace(rank, dims);
  
  // Create new datatype for the dataset
  FloatType datatype(PredType::NATIVE_FLOAT);
  
  // Create the dataset
  DataSet dataset = file.createDataSet(DS_NAME, datatype, dataspace);
  
  // Set up write buffer 'matrix'
  int q, r, s;
  float value;
  float matrix[dim1][dim2][dim3];
  for (q = 0; q &lt; dim1; q++)
  for (r = 0; r &lt; dim2; r++)
  for (s = 0; s &lt; dim3; s++)
  {
      value = 1.111 + (q * r * s);
      matrix[q][r][s] = value;
  }
  
  // Write data to the dataset
  dataset.write(matrix, datatype);
  
  // Create new dataspace for attribute
  DataSpace attr_dataspace = DataSpace(H5S_SCALAR);
  
  // Create new string datatype for attribute
  StrType strdatatype(PredType::C_S1, 256); // of length 256 characters
  
  // Set up write buffer for attribute
  const H5std_string strwritebuf("This attribute is of type StrType");
  
  // Create attribute and write to it
  Attribute myatt_in = dataset.createAttribute(ATTR_NAME, strdatatype, attr_dataspace);
  myatt_in.write(strdatatype, strwritebuf);
  
  // Set up read buffer for attribute
  H5std_string strreadbuf("");
  
  // Open attribute and read its contents
  Attribute myatt_out = dataset.openAttribute(ATTR_NAME);
  myatt_out.read(strdatatype, strreadbuf);
  
  // Display attribute contents
  cout &lt;&lt; "Attribute contents: " &lt;&lt; strreadbuf &lt;&lt; endl;
  
  return 0;
  }
  </code></pre>