如何正確的將HDF5加入到項目中進行編譯(霧)?!


//-----------------------------------------------------------------------

//更新(重要):請直接使用1.8.15版本

//這都是新版本的問題

//-----------------------------------------------------------------------

1 什么是HDF5

官方解釋:

HDF5 is a unique technology suite that makes possible the management of extremely large and complex data collections.

看起來HDF5就是一種用來存儲各種數據的一個容器/管理者。

2 為什么要弄這個組件到項目中去?

鑒於很多模型都使用這個格式進行數據存儲,所以在測試項目是難免會用到HDF5這個部分。所以這里對其加入到項目中做了以下總結。

3 將HDF5加入到項目需要那幾步?可能會遇到什么問題了?

大體上可以總結為三個部分:

(1)下載合適的部分

  這個當然難不到聰明的你了,放一個鏈接:https://support.hdfgroup.org/HDF5/release/obtain518.html  

選擇 Windows 64-bit (No SZIP)   [1]   Compilers:   CMake VS 2013 C, C++, IVF 15

  or (https://support.hdfgroup.org/HDF5/release/obtain5.html)

  注意:這里選擇了x64版本

(2)添加到項目中

Add the header path to the "Include Directories" setting.

  eg:C:\Program Files\HDF_Group\HDF5\1.8.18\include

Add the library path to the "Library Directories" setting.

  eg:C:\Program Files\HDF_Group\HDF5\1.8.18\lib

  添加頭文件和庫文件到C++目錄中去,

  添加HDF5的bin文件到環境path中: eg:C:\Program Files\HDF_Group\HDF5\1.8.18\bin

Select Linker->Input and beginning with the
"Additional Dependencies" line, enter the library names. The
external libraries should be listed first, followed by the HDF5
library, and then optionally the HDF5 High Level, Fortran or C++
libraries. For example, to compile a C++ application, enter:

  szip.lib zlib.lib hdf5.lib hdf5_cpp.lib

  添加合適的lib進行編譯

  由於我選擇了 NoSZIP的版本,結果就是  

zlib.lib hdf5.lib hdf5_cpp.lib

(3)編譯

  進行了上述的操作了就完成了99%,為什么?

  接下來就會遇到 error LNK2001: 無法解析的外部符號 _H5T_NATIVE_DOUBLE_g

  這樣的問題,所以bing搜索找到了解決方案():

  《1》http://www.cnblogs.com/yeahgis/p/3141441.html

  《2》http://www.xuebuyuan.com/1267127.html

  but these solutions don't work. why?

  很是疑惑的我想着官方網站能不能給我一些提示:https://support.hdfgroup.org/HDF5/release/obtain518.html  

  下面有一個行字比較醒目:To use the shared libraries on Windows with Visual Studio you must specify the H5_BUILT_AS_DYNAMIC_LIB compile definition.

  是的將H5_BUILT_AS_DYNAMIC_LIB加入到編譯器預編譯選項,就解決了上面了問題。

  

文章參考:

1. http://www.cnblogs.com/nwpuxuezha/p/4655014.html

2. http://www.cnblogs.com/yeahgis/p/3141441.html

3. http://www.xuebuyuan.com/1267127.html

4. https://support.hdfgroup.org/HDF5/release/obtain518.html

5. https://support.hdfgroup.org/HDF5/release/obtain5.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM