zoukankan      html  css  js  c++  java
  • linux环境下安装opencv (c++) 编译undefined reference错误的解决办法

    报错信息

    $ make
    [ 50%] Linking CXX executable DisplayImage
    /usr/bin/ld: warning: libhdf5.so.103, needed by /usr/lib/libopencv_hdf.so.4.1.1, not found (try using -rpath or -rpath-link)
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Dread' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Fcreate'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5T_NATIVE_UCHAR_g' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tget_size'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5check_version' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tget_array_dims2'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tclose' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Dopen2'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5open' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Sset_extent_simple'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5T_NATIVE_INT32_g' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5T_NATIVE_SCHAR_g'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Screate_simple' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Aget_type'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tcreate' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Awrite'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Fclose' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tset_strpad'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Gclose' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Aopen'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tget_class' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Gcreate2'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Aread' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Dclose'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Pset_deflate' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Adelete'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5P_CLS_DATASET_CREATE_ID_g' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Acreate2'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Dget_create_plist' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Aopen_name'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Eset_auto2' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Sselect_hyperslab'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Pset_chunk' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Pget_layout'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5P_CLS_LINK_ACCESS_ID_g' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Pget_chunk'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tinsert' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tequal'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Dget_space' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Aget_space'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Fis_hdf5' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Dget_type'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5T_NATIVE_FLOAT_g' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5T_NATIVE_USHORT_g'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Pcreate' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Eget_auto2'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Aclose' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tset_size'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tarray_create2' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Pclose'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Sget_simple_extent_ndims' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Screate'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Dwrite' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Dextend'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tget_super' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tget_native_type'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Lexists' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5T_NATIVE_INT_g'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5T_C_S1_g' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Tcopy'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Sclose' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5T_NATIVE_SHORT_g'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5T_NATIVE_DOUBLE_g' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Sget_simple_extent_dims'
    /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Dcreate2' /usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to H5Fopen'
    collect2: 错误:ld 返回 1
    make[2]: *** [CMakeFiles/DisplayImage.dir/build.make:133:DisplayImage] 错误 1
    make[1]: *** [CMakeFiles/Makefile2:76:CMakeFiles/DisplayImage.dir/all] 错误 2
    make: *** [Makefile:84:all] 错误 2

    解决方案

    安装软件包:
    vtk hdf5 glew

    参考文献

    https://stackoverflow.com/questions/57602675/building-a-hollow-world-error-using-cmake-and-opencv-undefined-reference-to-v

  • 相关阅读:
    axios
    es6
    $route监听路由变化
    容易挂
    自定义全局组件/插件
    eslintrc.js
    dev-server.js
    webpack-dev-server.js
    怎么消除间隔间的空白字符
    es6语法
  • 原文地址:https://www.cnblogs.com/zbqhc/p/11488164.html
Copyright © 2011-2022 走看看