Compiling HDF5 with the multithread, static version of the run-time library

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](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](https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx) , 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

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

my experiences on Windows with Visual Studio is that you _never_ really want to link against the MSVCPP runtime statically. This just causes all sorts of issues during runtime for all the reasons stated in other replies. If you make all your dependent libraries link against the Multi-threaded shared runtime libraries then you only have to include those with your program which is straight forward to do. CMake/QMake/Boost build can all find these libraries for you and include them in a package. My own project (http://github.com/dream3d) uses Qt, Boost, HDF5, Qwt, Eigen and OpenBLAS on windows and all are linked against the C/CPP shared-multi-threded runtime libs and we don't have any problems. Again, your case may be different from ours but in the last 8 years this has been the only way for our project to work consistently and without errors on Windows.

Mike Jackson
BlueQuartz Software

···

On Jul 20, 2015, at 11:15 AM, Samer Afach <webmaster@afach.de> 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.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

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:hdf-forum-bounces@lists.hdfgroup.org] On Behalf Of
Allen Byrne
Sent: Monday, July 20, 2015 11:36 AM
To: hdf-forum@lists.hdfgroup.org
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.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

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 [] On Behalf Of
Allen Byrne
Sent: Monday, July 20, 2015 11:36 AM
To: 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:
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.
Twitter:


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

mailto:hdf-forum-bounces@lists.hdfgroup.orghdf-forum@lists.hdfgroup.orghttps://www.hdfgroup.org/HDF5/release/cmakebuild.htmlHdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

Dear Mike:

Thank you for this information. I'll keep that in mind.

All the best,

Samer
···

On 7/20/2015 8:03 PM, Michael Jackson
wrote:

  my experiences on Windows with Visual

Studio is that you never really want to link against the MSVCPP
runtime statically. This just causes all sorts of issues during
runtime for all the reasons stated in other replies. If you make
all your dependent libraries link against the Multi-threaded
shared runtime libraries then you only have to include those with
your program which is straight forward to do. CMake/QMake/Boost
build can all find these libraries for you and include them in a
package. My own project (http://github.com/dream3d )
uses Qt, Boost, HDF5, Qwt, Eigen and OpenBLAS on windows and all
are linked against the C/CPP shared-multi-threded runtime libs and
we don’t have any problems. Again, your case may be different from
ours but in the last 8 years this has been the only way for our
project to work consistently and without errors on Windows.

Mike Jackson

BlueQuartz Software

On Jul 20, 2015, at 11:15 AM, 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](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](https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx) , 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.

          Hdf-forum@lists.hdfgroup.org

          [http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)

          Twitter:�[](https://twitter.com/hdf5)


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

webmaster@afach.dehttps://twitter.com/hdf5Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

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:hdf-forum-bounces@lists.hdfgroup.org] 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:hdf-forum-bounces@lists.hdfgroup.org] On Behalf Of

Allen Byrne

Sent: Monday, July 20, 2015 11:36 AM

To: hdf-forum@lists.hdfgroup.org<mailto:hdf-forum@lists.hdfgroup.org>

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.

Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>

http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

Twitter: https://twitter.com/hdf5

_______________________________________________

Hdf-forum is for HDF software users discussion.

Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>

http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

Twitter: https://twitter.com/hdf5