Hi Samer, I think you'll be ok with a statically linked HDF5 library as long as you don't build HDF5 with the thread-safe feature. Just be careful to use the H5free_memory function to free memory if you use one of the rare HDF5 API calls that requires you to free memory returned to you by the HDF5 library. This will ensure that you are freeing the allocated memory with the same allocator that the HDF5 library is using. The HDF5 reference manual (https://www.hdfgroup.org/HDF5/doc/RM/RM_H5Front.html) will clearly document when you are responsible for freeing memory (again, it's very unusual).
Dana From: Hdf-forum [mailto:[email protected]] On Behalf Of Samer Afach Sent: Monday, July 20, 2015 12:08 PM To: HDF Users Discussion List Subject: Re: [Hdf-forum] Compiling HDF5 with the multithread, static version of the run-time library Dear Dana: Thank you for this information. I don't use any multithreading in my program that has to do with HDF5. All my HDF5 files are read in a single thread. My use of HDF5 files is barely reading them with simple h5open() and h5read() and also reading some attributes. I don't use any sophisticated functionality such as plugins and VFD. Can this still cause problems? If yes, then this is a huge problem for me, because I need HDF5 to be compatible with my other libraries. Please suggest a solution. All the best, Samer On 7/20/2015 5:44 PM, Dana Robinson wrote: Hi Samer, A fully static thread-safe build on Windows won't work correctly. We use the HDF5 shared library entry points to set up thread-local storage for things like error and function stacks. While you may get CMake to build you an HDF5 shared library that is statically linked to the CRT, we don't support it. We disabled it due to potential problems with memory being allocated in one statically linked CRT and freed in another (e.g.: in plugins, user virtual file drivers, etc). Dana Robinson Software Engineer The HDF Group -----Original Message----- From: Hdf-forum [mailto:[email protected]] On Behalf Of Allen Byrne Sent: Monday, July 20, 2015 11:36 AM To: [email protected]<mailto:[email protected]> Subject: Re: [Hdf-forum] Compiling HDF5 with the multithread, static version of the run-time library To build HDF5 fully static using CMake, you must enable the UserMacro feature. See the short section, "VII. User Defined Options for HDF5 Libraries with CMake" in the INSTALL_CMake.txt file in the release_docs folder. Allen On Monday, July 20, 2015 05:15:56 PM Samer Afach wrote: Dear pros: I'm trying to compile the HDF5 library to make it compatible with the other libraries I'm using in my program. I'm using Visual Studio 2013. What I'm doing is that I'm using the build files from this page: https://www.hdfgroup.org/HDF5/release/cmakebuild.html And then using "build-VS2013-32.bat" to run the build. I need visual studio to compile the HDF5 library with the flag /MT, which is the multithread, static version of the run-time library in visual studio. Although shared libraries are turned off, it doesn't do it. I tried also modifying "build-VS2013-32.bat" contents from ctest -S HDF518config.cmake,32-VS2013 -C Release -V -O hdf518.log to ctest -S HDF518config.cmake,32-VS2013 -C Release -V -O hdf518.log --enable-parallel --enable-static-exec --disable-shared and that doesn't work. I don't see the /MT flag enabled in the library settings in the lib folder. How can I add this flag to the compilation of HDF5? This is very important because all my other libraries (Qt, boost, openssl, etc...) are compiled with that. HDF5 is causing a huge linking problem without that flag. Thank you. All the best, Samer _______________________________________________ Hdf-forum is for HDF software users discussion. [email protected]<mailto:[email protected]> http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org Twitter: https://twitter.com/hdf5 _______________________________________________ Hdf-forum is for HDF software users discussion. [email protected]<mailto:[email protected]> http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org Twitter: https://twitter.com/hdf5
_______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org Twitter: https://twitter.com/hdf5
