我有一个专门用cmake . -> make
构建的应用程序,它似乎使用Qt4库(CMakeLists文件的一部分):
include_directories("/usr/include/qt4/QtXml")
include_directories("/usr/include/qt4")
include_directories("/usr/include/qt4/Qt")
include_directories("/usr/include/qt4/QtCore")
include_directories("/usr/include/qt4/QtXml")
include_directories("/usr/include/qt4/QtGui")
include_directories("/usr/include/qt4/QtOpenGL")
ADD_DEFINITIONS(${QT_DEFINITIONS})
if(EXISTS "${ROOT}/usr/lib/x86_64-linux-gnu/libQGLViewer.so")
message(STATUS "Found qglviewer2, linking QGLViewer")
set(QGLVIEWER QGLViewer)
else()
message(STATUS "Did not find qglviewer2, linking qglviewer-qt4")
set(QGLVIEWER qglviewer2-qt4)
endif()
FIND_PACKAGE(Qt4 REQUIRED)
QT4_WRAP_CPP(onlinefusion_HEADERS_MOC onlinefusionviewer.hpp)
add_executable(onlinefusion
onlinefusionviewer_main.cpp
onlinefusionviewer.cpp
${onlinefusion_HEADERS_MOC}
)
target_link_libraries(onlinefusion
geometryfusion_mipmap_cpu geometryfusion_aos
camerautils
auxiliary
${OpenCV_LIBS}
${QGLVIEWER}
QtCore QtGui QtOpenGL
GL GLU glut GLEW
boost_thread
boost_system
)
这个程序构建正常,似乎我已经在我的Ubuntu 16.04上包含了所有必需的Qt4。然而,启动程序会导致崩溃,其中包含对Qt5的大量引用:
*** Error in `./onlinefusion': realloc(): invalid pointer: 0x00007fdbd8a89820 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fdbd449e7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x851d0)[0x7fdbd44ac1d0]
/lib/x86_64-linux-gnu/libc.so.6(realloc+0x22f)[0x7fdbd44aad3f]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN9QListData7reallocEi+0x1f)[0x7fdbd32179cf]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN9QListData6appendEi+0x81)[0x7fdbd3217aa1]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(+0x1d6d78)[0x7fdbd32e3d78]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_Z21qRegisterResourceDataiPKhS0_S0_+0x2e6)[0x7fdbd32dfb16]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(+0x7bcc3)[0x7fdbd3188cc3]
/lib64/ld-linux-x86-64.so.2(+0x104ea)[0x7fdbd8d404ea]
/lib64/ld-linux-x86-64.so.2(+0x105fb)[0x7fdbd8d405fb]
/lib64/ld-linux-x86-64.so.2(+0xcfa)[0x7fdbd8d30cfa]
我尝试将上面的CMakeLists中的链接库QtCore QtGui QtOpenGL
更改为系统中存在的libQtCore.so.4 libQtGui.so.4 libQtOpenGL.so.4
,但它仍然会在引用libQt5Core
时崩溃。
我可以做些什么来正确构建它?看起来只是finding package for Qt4无效。
Upd:ldd
输出确实包含Qt5库:
linux-vdso.so.1 => (0x00007ffc6c714000)
libQGLViewer.so.2 => /usr/lib/x86_64-linux-gnu/libQGLViewer.so.2 (0x00007fce9dba3000)
libQtCore.so.4 => /usr/lib/x86_64-linux-gnu/libQtCore.so.4 (0x00007fce9d6af000)
libQtGui.so.4 => /usr/lib/x86_64-linux-gnu/libQtGui.so.4 (0x00007fce9c9bb000)
libQtOpenGL.so.4 => /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4 (0x00007fce9c6b9000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 (0x00007fce9c445000)
libGLEW.so.1.13 => /usr/lib/x86_64-linux-gnu/libGLEW.so.1.13 (0x00007fce9c1c1000)
libboost_thread.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.58.0 (0x00007fce9bf9b000)
libboost_system.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0 (0x00007fce9bd97000)
libopencv_calib3d.so.3.1 => /usr/local/lib/libopencv_calib3d.so.3.1 (0x00007fce9ba1a000)
libopencv_video.so.3.1 => /usr/local/lib/libopencv_video.so.3.1 (0x00007fce9b694000)
libopencv_highgui.so.3.1 => /usr/local/lib/libopencv_highgui.so.3.1 (0x00007fce9b452000)
libopencv_imgcodecs.so.3.1 => /usr/local/lib/libopencv_imgcodecs.so.3.1 (0x00007fce9b0f6000)
libopencv_core.so.3.1 => /usr/local/lib/libopencv_core.so.3.1 (0x00007fce9a3c2000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fce9a040000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fce99d36000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fce99b20000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fce99903000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fce99539000)
libGLU.so.1 => /usr/lib/x86_64-linux-gnu/libGLU.so.1 (0x00007fce992ca000)
libQt5OpenGL.so.5 => /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5 (0x00007fce99270000)
libQt5Widgets.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 (0x00007fce98be2000)
libQt5Gui.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007fce9869a000)
libQt5Xml.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Xml.so.5 (0x00007fce9865e000)
libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007fce98187000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fce97f6d000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fce97d69000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fce97a57000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fce9784f000)
/lib64/ld-linux-x86-64.so.2 (0x000055d2300f1000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fce9760c000)
libaudio.so.2 => /usr/lib/x86_64-linux-gnu/libaudio.so.2 (0x00007fce973f2000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007fce971cd000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fce96f23000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fce96ccf000)
libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007fce96ac7000)
libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007fce968ad000)
libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007fce9669c000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fce96492000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fce96280000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fce95f45000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fce95d1c000)
libxcb-dri3.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0 (0x00007fce95b18000)
libxcb-present.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-present.so.0 (0x00007fce95915000)
libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007fce9570e000)
libxshmfence.so.1 => /usr/lib/x86_64-linux-gnu/libxshmfence.so.1 (0x00007fce9550a000)
libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007fce952db000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007fce950d8000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007fce94ed1000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007fce94ccf000)
libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007fce94ab6000)
libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007fce948b0000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fce9468e000)
libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007fce94488000)
libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007fce94278000)
libopencv_features2d.so.3.1 => /usr/local/lib/libopencv_features2d.so.3.1 (0x00007fce93fab000)
libopencv_flann.so.3.1 => /usr/local/lib/libopencv_flann.so.3.1 (0x00007fce93d51000)
libopencv_imgproc.so.3.1 => /usr/local/lib/libopencv_imgproc.so.3.1 (0x00007fce9230e000)
libQt5Test.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Test.so.5 (0x00007fce922da000)
libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007fce92080000)
libwebp.so.5 => /usr/lib/x86_64-linux-gnu/libwebp.so.5 (0x00007fce91e24000)
libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007fce91bb1000)
libjasper.so.1 => /usr/lib/x86_64-linux-gnu/libjasper.so.1 (0x00007fce91959000)
libIlmImf-2_2.so.22 => /usr/lib/x86_64-linux-gnu/libIlmImf-2_2.so.22 (0x00007fce9148b000)
libHalf.so.12 => /usr/lib/x86_64-linux-gnu/libHalf.so.12 (0x00007fce91248000)
libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007fce90fe9000)
libicui18n.so.55 => /usr/lib/x86_64-linux-gnu/libicui18n.so.55 (0x00007fce90b87000)
libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007fce907f2000)
libpcre16.so.3 => /usr/lib/x86_64-linux-gnu/libpcre16.so.3 (0x00007fce9058c000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fce9031b000)
libXt.so.6 => /usr/lib/x86_64-linux-gnu/libXt.so.6 (0x00007fce900b2000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fce8feae000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fce8fca5000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fce8faa0000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fce8f899000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fce8f677000)
libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007fce8f468000)
libIex-2_2.so.12 => /usr/lib/x86_64-linux-gnu/libIex-2_2.so.12 (0x00007fce8f24a000)
libIlmThread-2_2.so.12 => /usr/lib/x86_64-linux-gnu/libIlmThread-2_2.so.12 (0x00007fce8f043000)
libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007fce8ee1d000)
libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007fce8d366000)
新版CMakeLists:
add_subdirectory(camerautils)
add_subdirectory(auxiliary)
#add_subdirectory(auxiliaryGPU)
#add_subdirectory(libelas)
#add_subdirectory(output)
add_subdirectory(fusion)
#add_subdirectory(fusionGPU)
#add_subdirectory(sophus)
#add_subdirectory(filesystem)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
if(EXISTS "${ROOT}/usr/lib/x86_64-linux-gnu/libQGLViewer.so")
message(STATUS "Found qglviewer2, linking QGLViewer")
set(QGLVIEWER QGLViewer)
else()
message(STATUS "Did not find qglviewer2, linking qglviewer-qt4")
set(QGLVIEWER qglviewer2-qt4)
endif()
QT4_WRAP_CPP(onlinefusion_HEADERS_MOC onlinefusionviewer.hpp)
add_executable(onlinefusion
onlinefusionviewer_main.cpp
onlinefusionviewer.cpp
${onlinefusion_HEADERS_MOC}
)
target_link_libraries(onlinefusion
geometryfusion_mipmap_cpu geometryfusion_aos
camerautils
auxiliary
${OpenCV_LIBS}
${QGLVIEWER}
Qt4::QtCore Qt4::QtGui Qt4::QtOpenGL Qt4::QtXml
${QT4_QTCORE_LIBRARY}
GL GLU glut GLEW
boost_thread
boost_system
)