当前位置:   article > 正文

Ubuntu安装opencv的时候报undefined reference_/usr/bin/ld: /lib/x86_64-linux-gnu/libgio-2.0.so.0

/usr/bin/ld: /lib/x86_64-linux-gnu/libgio-2.0.so.0: undefined reference to `

导读

在Ubuntu16.04上安装opencv4的时候,cmake的时候报了很多undefined reference,错误信息如下:

//usr/lib/x86_64-linux-gnu/libgtk-3.so.0: undefined symbol: g_list_model_get_type
//usr/lib/x86_64-linux-gnu/libgio-2.0.so.0: undefined reference to g_option_group_unref’
//usr/lib/x86_64-linux-gnu/libgio-2.0.so.0: undefined reference to g_thread_pool_move_to_front’
//usr/lib/x86_64-linux-gnu/libgio-2.0.so.0: undefined reference to `g_sequence_is_empty’
collect2: error: ld returned 1 exit status
apps/visualisation/CMakeFiles/opencv_visualisation.dir/build.make:108: recipe for target ‘bin/opencv_visualisation’ failed
make[2]: *** [bin/opencv_visualisation] Error 1
CMakeFiles/Makefile2:7756: recipe for target ‘apps/visualisation/CMakeFiles/opencv_visualisation.dir/all’ failed
make[1]: *** [apps/visualisation/CMakeFiles/opencv_visualisation.dir/all] Error 2

原因分析

  • 先去/usr/lib/x86_64-linux-gnu/目录下查看是否安装相应的依赖,如果没安装通过下面的命令进行安装
sudo apt install build-essential cmake git pkg-config libgtk-3-dev \
    libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
    libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
    gfortran openexr libatlas-base-dev python3-dev python3-numpy \
    libtbb2 libtbb-dev libdc1394-22-dev
  • 1
  • 2
  • 3
  • 4
  • 5
  • 如果存在更改cmake的命令如下进行编译
cmake -DCMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=ON -DBUILD_EXAMPLES=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..
  • 1
  • make编译
make -j8
  • 1
  • 安装
sudo make install
  • 1
  • 检查opencv是否安装成功
pkg-config --cflags opencv4
#安装成功会输出
-I/usr/local/include/opencv4
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/185109
推荐阅读
相关标签
  

闽ICP备14008679号