word_no_bug 2021-08-21 10:20 采纳率: 50%
浏览 274
已结题

cmake链接hdf5库文件报错:找不到函数undefined reference to `H5::H5File::~H5File()'

使用cmake想在c++上读取.h5文件,但是一直报错找不到函数,链接库的时候没有报错。

cmakelists:

project(test)
cmake_minimum_required(VERSION 3.18)
find_package(HDF5 COMPONENTS C CXX HL REQUIRED)
link_directories( ${HDF5_LIBRARY_DIRS} )
include_directories( ${HDF5_INCLUDE_DIRS} )
add_executable( test test.cpp )
target_link_libraries(test ${HDF5_CXX_LIBRARIES} ${HDF5_LIBRARIES})

报错:

[build] C:/project/test_hdf5/test.cpp:9: undefined reference to `H5::H5File::H5File(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, H5::FileCreatPropList const&, H5::FileAccPropList const&)'
[build] C:/project/test_hdf5/test.cpp:9: undefined reference to `H5::H5File::~H5File()'
[build] C:/project/test_hdf5/test.cpp:9: undefined reference to `H5::H5File::~H5File()'
[build] CMakeFiles\test.dir/objects.a(test.cpp.obj):test.cpp:(.rdata$.refptr._ZN2H517FileCreatPropList7DEFAULTE[.refptr._ZN2H517FileCreatPropList7DEFAULTE]+0x0): undefined reference to `H5::FileCreatPropList::DEFAULT'
[build] CMakeFiles\test.dir/objects.a(test.cpp.obj):test.cpp:(.rdata$.refptr._ZN2H515FileAccPropList7DEFAULTE[.refptr._ZN2H515FileAccPropList7DEFAULTE]+0x0): undefined reference to `H5::FileAccPropList::DEFAULT'

实在是找不到为什么了,麻烦大家看看分析一下原因

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 8月29日
    • 创建了问题 8月21日