[CMake] FindHDF5 works on Linux, fails on Windows
Ohs Nicholas
nicholas.ohs at hest.ethz.ch
Fri Nov 18 07:38:52 EST 2016
Hello,
When I use FindHDF5 to setup my project it works perfect on Arch-Linux to produce make scripts. However, when I generate Visual Studio 2015 64bit solutions, I get an error during compile, as Visual Studio is trying to link against hdf5_cpp.dll directly throwing a LNK1107 error. Instead of linking directly against the *.dll I think on windows it should link against the corresponding *.lib. Is this a bug in FindHDF5? Can anybody reproduce the issue?
Info about the System:
- Windows 10 64bit
- Visual Studio 2015 64bit project
- CMake 3.7.0
- HDF5 1.10.0
Here what I do:
Create build folder, call: "cmake -G "Visual Studio 14 2105 Win64" .."
With part of the output being
"Found HDF5: C:/Program Files/HDF_Group/HDF5/1.10.0/bin/hdf5_cpp.dll (found version "1.10.0") found components: CXX"
Here is the CMakeLists.txt
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project("justTesting")
find_package(HDF5 COMPONENTS CXX REQUIRED)
include_directories(${HDF5_INCLUDE_DIRS})
add_executable(hdf5_test test.cpp)
target_link_libraries(hdf5_test ${HDF5_CXX_LIBRARIES})
and here the test.cpp
#define H5_BUILT_AS_DYNAMIC_LIB
#include <H5Cpp.h>
int main()
{
H5::H5File file = H5::H5File("test.h5", H5F_ACC_EXCL);
file.close();
}
Then I open the solution, click on ALL_BUILD and build it. The output is in short:
LNK1107 Invalid or corrupt file: cannot read at 0x380, File: hdf5_cpp.dll
The entire log:
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1> Checking Build System
1> CMake does not need to re-run because C:/=======================/test_hdf5_cmake/build/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: hdf5_test, Configuration: Debug x64 ------
2> Building Custom Rule C:/=======================/test_hdf5_cmake/CMakeLists.txt
2> CMake does not need to re-run because C:\ =======================\test_hdf5_cmake\build\CMakeFiles\generate.stamp is up-to-date.
2> test.cpp
2>c:\program files\hdf_group\hdf5\1.10.0\include\H5Exception.h(93): warning C4251: 'H5::Exception::detail_message': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'H5::Exception'
2> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2633): note: see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
2>c:\program files\hdf_group\hdf5\1.10.0\include\H5Exception.h(94): warning C4251: 'H5::Exception::func_name': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'H5::Exception'
2> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2633): note: see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
2>C:\Program Files\HDF_Group\HDF5\1.10.0\bin\hdf5_cpp.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x380
3>------ Build started: Project: ALL_BUILD, Configuration: Debug x64 ------
3> Building Custom Rule C:/=======================/test_hdf5_cmake/CMakeLists.txt
3> CMake does not need to re-run because C:\=======================\test_hdf5_cmake\build\CMakeFiles\generate.stamp is up-to-date.
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
So my question again from above:
- Can anybody reproduce the issue?
- Is this a bug in FindHDF5?
Cheers
Nicholas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161118/ad56cc73/attachment.html>
More information about the CMake
mailing list