Need Help Using HDF5

Hello,

I’m trying to use the hdf5 libraries to write a small c program to convert csv files to an hdf5 file. I’m on a windows machine, and I’m having a hard time getting to the point where I can actually use the functions/libraries. I’ve installed Cmake, and the prebuilt HDF5 libraries, but seemingly nothing that I do will get it such that any compiler I use sees those libraries. I’ve never used Cmake before, only made basic c programs with gcc. This all seems a bit overkill for what I’m doing. What is the easiest way for me to start using the HDF5 libaries so that they work with a #include in a c file?

Thank you!

Since your planning to write a simple C program(assuming that your using Visual studio), don’t use Cmake. Just get the latest HDF5 libraries and follow this for linking and including headers https://stackoverflow.com/questions/212492/how-do-you-add-external-libraries-for-compilation-in-vc.

I can use visual studio

What do you mean “get the latest libraries”? Do you have a link? I’m sorry to have to be spoon fed, but this entire project continues to baffle me. Also, that stackoverflow link is not clear about what to do either once I have the libaries.
Which libraries? From where? What about the header files? :dizzy_face:

brendan.bogan

      [Brendan Bogan](https://forum.hdfgroup.org/u/brendan.bogan)




    September 16

Hello,

I’m trying to use the hdf5 libraries to write a small c program to convert csv files to an hdf5 file. I’m on a windows machine, and I’m having a hard time getting to the point where I can actually use the functions/libraries. I’ve installed Cmake, and the prebuilt HDF5 libraries, but seemingly nothing that I do will get it such that any compiler I use sees those libraries. I’ve never used Cmake before, only made basic c programs with gcc. This all seems a bit overkill for what I’m doing. What is the easiest way for me to start using the HDF5 libaries so that they work with a #include in a c file?

The HDF5 libraries are a not ideal for someone with your limited experience. It seems your interest is more on just getting the data into csv files than becoming an HDF5 expert. For that, you could use a more accessible language such as Python or R. If you prefer to focus on C, you might consider https://root.cern.ch/. Root has its own data format, but there are programs to convert HDF5 files to ROOT. If you plan to use the .csv files with Excel, consider https://support.hdfgroup.org/news/announcements/AnnouncingPyHexad.pdf

Hello!

You can download pre-built binaries for WIndows from here: https://www.hdfgroup.org/downloads/hdf5/

You will need to log in to download the binaries. If you do not have an account, you can register by clicking on the blue-outlined button “Create Free Account” at the top right of the page.

You will find Windows binaries for Window7 and Windows 10 64-bit for VS 2015 in the table on that page:
hdf5-1.10.5-Std-win10_64-vs14.zip
hdf5-1.10.5-Std-win7_64-vs14.zip

If you have a different version of VS, you will need to build HDF5 from source. You can download the source code packaged for CMake (CMake-hdf5-1.10.5.zip) and follow the link for Building HDF5 with CMake. See: HDF5 1.10.5

Once you have obtained the binaries (and uncompressed and installed them), you can either use CMake or Visual Studio to compile your application.

In the top directory of the built binary distribution, you will see these files (among others):

bin/ - HDF5 utilities
include/ - HDF5 include files
lib/ - HDF5 libraries
USING_HDF5_VS.txt

The USING_HDF5_VS.txt file contains instructions for building an application with Visual Studio. The instructions may vary slightly depending on your version of Visual Studio, but basically you must do the following in VS:

  1. specify the H5_BUILT_AS_DYNAMIC_LIB compile definition if using shared libraries.
  2. add the path to the HDF5 include files to Include Directories.
  3. add the path to the HDF5 libraries to the Library Directories.
  4. specify the library names.

Then compile the application in VS.

If you wish to compile your application with CMake, the Building HDF5 with CMake page provides some instructions: Building HDF5 with CMake

Attached is a small program that reads a text file with values separated by commas, and creates an HDF5 file.

Hopefully, this helps you to get started! Feel free to contact me at the HDF Helpdesk if you have further questions: The HDF Help Desk

-Barbara
h5floatcs.c (2.0 KB)
floatcs.txt (252 Bytes)

Hey George,

I’ll be honest, I don’t really appreciate being told that I’m not capable of using the tool.

From all of the documentation I can find scattered across the HDF group website, and the rest of the internet, I got cmake to build a visual studio project that works, and once that was the case I got the code to work within a day. While I may not be familiar with these particular tools, this isn’t my first time around with C.

I think this is a great file format. Try not to scare too many new people away :slight_smile: If anything, maybe my concerns reflect the need for some clearer documentation on the part of the HDF group.

Thank you Barbara!

I’ve tried all of this. I’m using Visual Studio 2019. I believe I installed the prebuilt binaries, and somehow got cmake to make a Visual Studio project from your guy’s project framework. However, I still don’t understand what all it actually did and my solution explorer is a mess. When I make my own project, and try to manually setup the include and linker settings, it still doesn’t find the libraries I installed. I’m not quite sure what I’m missing, but I think there’s a step missing in your documentation.

If I could make a suggestion, maybe make a PDF for new users of the library that has pictures for new users to go from downloading the library from your website to building a standalone visual studio project.

Hi Brendan,

Our pre-built binaries are built with Visual Studio 2015 and 2017. To avoid
issues with different VS runtime libraries it is a good idea to use libraries
that are built with the same version of VS that is on your machine.

With regards to building HDF5 applications in VS, one thing you can do is
use the solution files that CMake creates.

The HDF5 CMake source code (CMake-hdf5-1.10.5.zip) contains examples that
you can build. After you build HDF5 with CMake you can uncompress the
examples zip file that is provided (HDF5Examples-1.12.4-Source.zip).

Then go into the HDF5Examples-1.12.4-Source\HDF5Examples directory and
follow the instructions to build them (Using_CMake.txt). Once they are built,
you will find the solution files in the build\ directory.

It’s been a while since I have tried this. Let me know if you encounter any
issues!

-Barbara