3

I'm currently using hdf5 1.8.15 on Windows 7 64bit. The sourcecode of my software is saved in files using utf8 encoding.

As soon as I call any hdf5 function supporting std:: string, the ouput gets cryptic

enter image description here

But if I use const char* instead of std::string, everything works fine. This applies also to the filename.

Here is a short sample:

std::string filename_ = "test.h5";    
H5::H5File file( filename_.c_str(), H5F_ACC_TRUNC); // works

H5::H5File file( filename_, H5F_ACC_TRUNC); // filename is not readable or
                                            // hdf5 throws an exception

I guess that this problem is caused by different encodings used in my source files and hdf5. But I'm not sure about this and found no solution allowing the use of std::strings. I would appreciate any idea which helps me with this issue.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
  • Sounds more like conflicting implementations of the standard library, or some other conflict. The encoding in your source file is 100% irrelevant. – molbdnilo Aug 18 '15 at 12:37
  • Ok thanks for the information. Instead of using the provided precompiled binaries I compiled hdf5 by myself and the error is gone. – user2445483 Aug 18 '15 at 15:05
  • @user2445483 Could you maybe describe in more detail what you did? Because I have the same issue, however, it is not gone after I compiled the hdf5 files by myself. – NOhs Apr 21 '16 at 17:47
  • Ok, i found the issue (see below). – NOhs Apr 21 '16 at 20:08

2 Answers2

1

I also had the same problem, and fixed it by changing all my std::string or h5std_string to literally:

5File file("myFile.h5", H5F_ACC_TRUNC);

Or use string.c_str() to change the string to const char.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
sorry_I_wont
  • 639
  • 1
  • 9
  • 16
0

I had exactly the same problem. The solution was, that I was in Debug-Mode in Visual Studio, whereas the libraries I linked against were build in Release-Mode. When I switched in Visual Studio to Release-Mode, the above error disappeared.

NOhs
  • 2,780
  • 3
  • 25
  • 59