解决ubuntu16.04 opencv2.4.13编译错误的过程

要在opencv中使用opengl

cmake -D CMAKE_BUILD_TYPE=Release Debug -D WITH_OPENGL=ON -D CMAKE_INSTALL_PREFIX=/usr/local .

没有添加opengl编译选项的时候是可以正常编译的,打开支持opengl编译就出现了下面的问题

开始出现的问题是找不到gtk/gtkgl.h,然后按照搜索的解决方法安装libgtkglext1-dev

sudo apt-get install libgtkglext1-dev后 make报下面的错误

//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

libgio找不到libglib,但是ldd /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0是可以看到libglib路径的

/opencv2/opencv-2.4.13$ ldd /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4800.1
    linux-vdso.so.1 =>  (0x00007ffd3ca0f000)
    libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fda5b7d1000)
    libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007fda5b5cd000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fda5b2bb000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fda5b0a1000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fda5ae7f000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fda5ac63000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fda5a89a000)
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fda5a692000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fda5a48d000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fda5a21d000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fda5a000000)
    /lib64/ld-linux-x86-64.so.2 (0x0000558ec38f2000)

不能单独配置使用opengl

使用下面的

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_TIFF=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..

你可能感兴趣的:(解决ubuntu16.04 opencv2.4.13编译错误的过程)