Ubuntu安装opencv的时候报undefined reference
导读在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: undefine
导读
在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
- 如果存在更改cmake的命令如下进行编译
cmake -DCMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=ON -DBUILD_EXAMPLES=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..
- make编译
make -j8
- 安装
sudo make install
- 检查opencv是否安装成功
pkg-config --cflags opencv4
#安装成功会输出
-I/usr/local/include/opencv4
更多推荐
所有评论(0)