Compiling errors using C++

Hi! I’m fairly new with HDF5 and I have been testing it and for the life of me I can’t make it work.
I intended to use it with Fortran but, for now, I’ve been testing it with C++.

I created a C++ console application project and tried the create.cpp example of the API. The compiler gives me some simple errors and once I fix them, it says
error LNK2038: mismatch detected for ‘_ITERATOR_DEBUG_LEVEL’: value ‘0’ doesn’t match value ‘2’ in ConsoleApplication1.obj

Is says too: Mismatch Detected for ‘RuntimeLibrary’ value ‘md_dynamicrelease’ doesn’t match value ‘mdd_dynamicdebug’.
I’ve tried changing the runtime library but all of the four libraries return an error.

I installed HDF5 in a path without spaces, as recommended, and then I followed the instructions in the SING_HDF5_VS.txt file.

In Linker->Input, in additional dependencies, I added the libaries that start with lib, otherwise Visual Studio tells me that some dependencies cannot be resolved.

I am currently using Visual Studio 2017 with Windows 7 64 bits. I tried the same process with Visual Studio 2013 and the same error arise.

Do you guys know what could be the problem?

Thanks.

I think you are using MS Visual Studio to build? I think that has to do with building the library with one of release/debug and your app with the other of debug/release. It has been a while since I’ve used that, so I am trying to recall from many moons back.

Hi! Yes, I’m usin MS Visual Studio to build.

Looking on the internet it seems that way, but if I try to use the other libraries, that is, the libraries that don’t start with lib (the non-static libraries) Visual Studio returns me an error, saying that it can’t resolve an external symbol (a HDF5 function).

So it seems I’m stuck using the static libraries. However, if I change the app to release, the error persists. So trying different combinations doesn’t seem to fix it.

If this is a new project without existing dependencies to current HDF5 C++ API you may want to give a try to alternatives presented in this webinar. H5CPP is a header only library supporting popular linear algebra libraries, STL vectors and raw pointers, in addition to it comes with LLVM based compiler assisted reflection and has good performance characteristics – on par with CAPI or in case of packet table exceeding it.

While currently windows installer is not yet available I suggest to download the project from this gitgub page and copy/ship the MIT licensed header files with your project.
The project comes with plenty examples, look through them – and if you have any questions shoot me an email.
best wishes: steven

Hi @iaparicio

I have the exact same problem, trying to use HDF5 in debug mode. Did you manage to find a solution? Thanks

Edit: I finally was able to use the library in debug mode, with hdf5.lib (instead of libhdf5.lib). What I was missing until now was the H5_BUILT_AS_DYNAMIC_LIB in the VS Preprocessor Definitions.