# Linking hdf5 in windows c++

**URL:** <https://forum.hdfgroup.org/t/linking-hdf5-in-windows-c/3110>\
**Category:** Hdf-forum archives\
**Created:** [January 17, 2014, 4:16pm UTC](https://forum.hdfgroup.org/t/linking-hdf5-in-windows-c/3110 "2014-01-17T16:16:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Llorens](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@Jose\_Llorens](https://forum.hdfgroup.org/u/Jose_Llorens)\
**Post date:** [January 17, 2014, 4:16pm UTC](https://forum.hdfgroup.org/t/linking-hdf5-in-windows-c/3110/1 "2014-01-17T16:16:29Z")

</div>

I have to provide a software running in Windows compiled with mingw for Win 7 x86\_64.  
Following some instructions [1], I got a static version of the libraries cross-compiled in a Linux box. Afterwords I moved the libraries to the Win 7 x86\_64. I have compiled the c examples without much trouble and check that the generated h5 files are correct. However when I try to do the same with a simple c++ example (create.cpp [2]) I get many errors, see for example:

This is the linking command:

g++ -o tst create.cpp -I./build\_win64/include -L./build\_win64/lib" -lhdf5\_cpp -lhdf5

Type of errors:  
1. Multiple definitions:  
C:\Users\Jose\Documents\HDF5\TEST\build\_win64\lib/libhdf5\_cpp.a(H5Exception.o):H5Exception.cpp:(.data$\_ZTIN2H59ExceptionE[\_ZTIN2H59ExceptionE]+0x0): multiple definition of `typeinfo for H5::Exception'

C:\Users\Jose\AppData\Local\Temp\cctPJEaw.o:1.cpp:(.rdata$\_ZTIN2H59ExceptionE[\_ZTIN2H59ExceptionE]+0x0): first defined here

2. Cannot get section contents:  
C:\Users\Jose\Documents\HDF5\TEST\build\_win64\lib/libhdf5\_cpp.a(H5Exception.o):H5Exception.cpp:(.data$\_ZTIN2H520IdComponentExceptionE[\_ZTIN2H520IdComponentExceptionE]+0xffffffffe8bf0040): Cannot get section contents - auto-import exception

3. A final ld error:  
c:/mingw-builds/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86\_64-w64-mingw32/4.8.1/../../../../x86\_64-w64-mingw32/bin/ld.exe: C:\Users\Jose\AppData\Local\Temp\cctPJEaw.o: bad reloc address 0x0 in section `.data'  
collect2.exe: error: ld returned 1 exit status

Any help would be welcome. Perhaps I am missing some flags either at cross-compiling the libraries in linux or compiling and linking in Win 7.

Jose.

[1] Works for versions 1.8.8 to 1.81.8.10-patch1. For 1.8.12 doesn't work.  
[http://www.beneaththewaves.net/Software/DaVincis\_Shadow\_Build\_Process\_-\_Cross-Compiling\_For\_Windows\_on\_Linux.html](http://www.beneaththewaves.net/Software/DaVincis_Shadow_Build_Process_-_Cross-Compiling_For_Windows_on_Linux.html)

[2][http://www.hdfgroup.org/ftp/HDF5/current/src/unpacked/c++/examples/create.cpp](http://www.hdfgroup.org/ftp/HDF5/current/src/unpacked/c++/examples/create.cpp)
