Hi Terry - not sure if this is applicable, I've used dev studio with dynamic 
libs for dev studio 2010, and a fairly old version of hdf (1.8.10), but I found 
the following "note to self" in the code that I wrote back then:
//Notes 
//1) The project should define H5_BUILT_AS_DYNAMIC_LIB as a preprocessor 
setting, otherwise
//the HDF5 exported global variables are not declared to be imported by us.
Steve Bissell

-----Original Message-----
From: Hdf-forum [mailto:[email protected]] On Behalf Of 
Terry McKiernan
Sent: 07 March 2016 04:18
To: [email protected]
Subject: [Hdf-forum] linking HDF5 with VS2015 C++ 64-bit only works with static 
libraries

Hi all,

I'm having trouble using HDF5 with C++ using Visual Studio Pro 2015.  
Below is a message I sent to [email protected]; I'm also sending it to this 
list in case someone else has run into the same problem.

The problem is, I can only link C++ programs when I use the static HDF5 
libraries (libszip.lib, libzlib.lib, libhdf5.lib, libhdf5_cpp.lib) but not with 
the dynamic libraries (szip.lib, zlib.lib, hdf5.lib, hdf5_cpp.lib).  When I 
link the static libraries, everything works fine
-- links, builds an exe, and the exe works.  When I try to link with the 
smaller dynamic libraries instead, I get unresolved symbol errors such as:

1>h5create.obj : error LNK2001: unresolved external symbol "public: 
static class H5::DataSpace const & const H5::DataSpace::ALL" 
(?ALL@DataSpace@H5@@2AEBV12@EB)
1>h5create.obj : error LNK2001: unresolved external symbol "public: 
static class H5::DSetCreatPropList const & const 
H5::DSetCreatPropList::DEFAULT" (?DEFAULT@DSetCreatPropList@H5@@2AEBV12@EB)
1>h5create.obj : error LNK2001: unresolved external symbol "public: 
static class H5::DSetMemXferPropList const & const 
H5::DSetMemXferPropList::DEFAULT" 
(?DEFAULT@DSetMemXferPropList@H5@@2AEBV12@EB)
1>h5create.obj : error LNK2001: unresolved external symbol "public: 
static class H5::FileAccPropList const & const H5::FileAccPropList::DEFAULT" 
(?DEFAULT@FileAccPropList@H5@@2AEBV12@EB)
1>h5create.obj : error LNK2001: unresolved external symbol "public: 
static class H5::FileCreatPropList const & const 
H5::FileCreatPropList::DEFAULT" (?DEFAULT@FileCreatPropList@H5@@2AEBV12@EB)
1>h5create.obj : error LNK2001: unresolved external symbol "public: 
static class H5::PredType const & const H5::PredType::NATIVE_INT" 
(?NATIVE_INT@PredType@H5@@2AEBV12@EB)


I am using Visual Studio Professional 2015 with the latest service packs.  Here 
is the C++ info from Visual Studio's About-Help dialog:

Microsoft Visual Studio Professional 2015 Version 14.0.24720.00 Update 1 
Microsoft .NET Framework Version 4.6.01055

Installed Version: Professional

Visual C++ 2015   <<serial number>>
Microsoft Visual C++ 2015

I downloaded HDF5 1.8.16 from
https://www.hdfgroup.org/HDF5/release/obtain5.html. Specifically I downloaded 
the Windows 64-bit version for "CMake VS 2015 C, C++, IVF 16", and installed it 
in the default directory under C:\Program Files.

I then created a new Visual Studio solution for a Win32 console application, 
and for the source code I used the C++ "create.cpp" example from the HDF site: 
https://www.hdfgroup.org/HDF5/doc/cpplus_RM/create_8cpp-example.html. In my 
Visual Studio project I added the include and lib directories to the compiler 
and linker paths, and added the HDF5 libraries (szip.lib, zlib.lib, hdf5.lib, 
hdf5_cpp.lib) to the linker "additional libraries" 
line.  I left everything else as the defaults.  When I compile, I get the 
unresolved symbol name errors mentioned at the top of this email.  
If I switch to the static libraries (libszip.lib, libzlib.lib, libhdf5.lib, 
libhdf5_cpp.lib) the errors go away.

To test my HDF5 installation, I downloaded CMake 3.4.3 and built the
HDF5 Examples that came with the 1.8.16 distribution.  That worked fine and I 
got 100% test cases passing (156 of 156, if I recall correctly).  
But, I notice that all the examples are in C rather than C++, so I suspect that 
is the root of the problem.

I looked into building the HDF5 libraries from source using CMake as suggested 
on the HDF site, but I see that while there are build scripts for VS2012 and 
VS2013, there is not one for VS2015.  I am new to CMake and didn't feel 
comfortable taking that on (yet) but I suppose I should learn.

Note that I also set up a Linux box (Mint 17.4), downloaded the HDF5 binary 
distribution for the 2.6 kernel, installed it and built the same sample 
application (create.cpp) without any trouble.  For that I was able to link with 
both the dynamic .so files and the static .a files.  
So my problem seems to be on Windows only.

Any help is appreciated.  Thanks!

Terry McKiernan

_______________________________________________
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

This mail has originated outside your organization, either from an external 
partner or the Global Internet.
Keep this in mind if you answer this message.



This email and its attachments may contain confidential and/or privileged 
information.  If you have received them in error you must not use, copy or 
disclose their content to any person.  Please notify the sender immediately and 
then delete this email from your system.  This e-mail has been scanned for 
viruses, but it is the responsibility of the recipient to conduct their own 
security measures. Airbus Operations Limited is not liable for any loss or 
damage arising from the receipt or use of this e-mail. 

Airbus Operations Limited, a company registered in England and Wales, 
registration number, 3468788.  Registered office:  Pegasus House, Aerospace 
Avenue, Filton, Bristol, BS34 7PA, UK.



_______________________________________________
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

Reply via email to