我有一个Qt / ROS / Qwt应用程序。一切都很顺利,直到我试图链接到Qwt。请注意,我使用的Qwt 6.1.2应该在Qt 5.5上运行。实际上,这些例子运行良好。
当我运行我的二进制文件时,即使我没有使用Qwt,它也会崩溃。我只需要将我的代码链接到Qwt即可。而且 - 我认为是这个问题 - gdb给出了以下错误:
ram received signal SIGSEGV, Segmentation fault.
0x00007ffff25eadfc in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
这是错误的,因为二进制文件应该使用Qt 5.5。为了让事情变得更奇怪,ldd给出了:
>> ldd dls_gui | grep 'Qt'
libQt5Widgets.so.5 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libQt5Widgets.so.5 (0x00007f684cadc000)
libQt5Gui.so.5 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libQt5Gui.so.5 (0x00007f684afad000)
libQt5Core.so.5 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libQt5Core.so.5 (0x00007f684a867000)
libQtSvg.so.4 => /usr/lib/x86_64-linux-gnu/libQtSvg.so.4 (0x00007f684862c000)
libQtGui.so.4 => /usr/lib/x86_64-linux-gnu/libQtGui.so.4 (0x00007f6847979000)
libQtCore.so.4 => /usr/lib/x86_64-linux-gnu/libQtCore.so.4 (0x00007f6847493000)
libicui18n.so.54 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libicui18n.so.54 (0x00007f6844e33000)
libicuuc.so.54 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libicuuc.so.54 (0x00007f6844a85000)
libicudata.so.54 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libicudata.so.54 (0x00007f684305b000)
我如何链接到Qt5和Qt4? Qwt似乎仅与Qt 5.5相关联:
>> ldd /usr/local/qwt-6.1.2/lib/libqwt.so | grep 'Qt'
libQt5PrintSupport.so.5 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libQt5PrintSupport.so.5 (0x00007fbcee13a000)
libQt5Svg.so.5 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libQt5Svg.so.5 (0x00007fbcedee5000)
libQt5OpenGL.so.5 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libQt5OpenGL.so.5 (0x00007fbcedc8e000)
libQt5Widgets.so.5 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libQt5Widgets.so.5 (0x00007fbced410000)
libQt5Gui.so.5 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libQt5Gui.so.5 (0x00007fbcecbfc000)
libQt5Core.so.5 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libQt5Core.so.5 (0x00007fbcec4b7000)
libicui18n.so.54 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libicui18n.so.54 (0x00007fbcea032000)
libicuuc.so.54 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libicuuc.so.54 (0x00007fbce9c84000)
libicudata.so.54 => /home/jcolmenares/Qt/5.5/gcc_64/lib/libicudata.so.54 (0x00007fbce825a000)
我的CMakeList.txt文件是:
cmake_minimum_required(VERSION 2.8.11)
project(dls_gui)
# Find the QtWidgets library
find_package(Qt5Widgets)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Qwt related
# list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_packages")
# find_package(Qwt REQUIRED)
find_path(QWT_INCLUDE_DIR qwt.h HINTS /usr/local/qwt-6.1.2/include)
find_library(QWT_LIBRARY qwt /usr/local/qwt-6.1.2/lib/)
include_directories(${QWT_INCLUDE_DIR})
# catkin related
catkin_package()
find_package(catkin REQUIRED COMPONENTS roscpp sensor_msgs urdf)
include_directories( ${catkin_INCLUDE_DIRS} include)
# source, header and resources files list
set(CPP_SOURCES src/main.cpp src/mainwindow.cpp src/basewidget.cpp src/rosQtNode.cpp
src/joints_sliders.cpp src/superslider.cpp src/support_polygon.cpp)
set(CPP_HDRS include/mainwindow.h include/basewidget.h include/rosQtNode.hpp
include/joints_sliders.hpp include/superslider.hpp include/support_polygon.hpp)
set(QRC_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dls_gui.qrc)
# Add the include directories for the Qt 5 Widgets module to# the compile lines.
include_directories(${Qt5Widgets_INCLUDE_DIRS} )
# Use the compile definitions defined in the Qt 5 Widgets module
add_definitions(${Qt5Widgets_DEFINITIONS})
# Generate headers from ui files
qt5_wrap_ui(UIS_HDRS src/mainwindow.ui)
# Generate moc files from cpp
qt5_wrap_cpp(MOC_SOURCES ${CPP_SOURCES} ${CPP_HDRS})
# Generate resources
qt5_add_resources(RESOURCES_RCC ${RESOURCE})
# Add compiler flags for building executables (-fPIE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} -std=c++11")
## Ros include dirs
include_directories(include ${catkin_INCLUDE_DIRS})
# Tell CMake to create the helloworld executable
add_executable(dls_gui ${CPP_SOURCES} ${UIS_HDRS} ${MOC_SOURCES} ${QRC_RESOURCES})
add_executable(testRos src/testRos.cpp)
qt5_use_modules(dls_gui Widgets)
#Link the helloworld executable to the Qt 5 widgets library.
target_link_libraries(dls_gui ${QWT_LIBRARY} Qt5::Widgets ${catkin_LIBRARIES} )
target_link_libraries(testRos ${catkin_LIBRARIES})
我不认为这与ROS有关,但重要的是说源代码是通过catkin_make等编译的。
最后但并非最不重要的是,qmake引用版本5.5:
>> qmake --version
QMake version 3.0
Using Qt version 5.5.0 in /home/jcolmenares/Qt/5.5/gcc_64/lib
编辑:要明确:我希望(需要)编译并链接到同一个Qtversión的所有内容。但不知何故,并没有发生。
答案 0 :(得分:1)
您需要与qwt-qt5
链接。
qwt
是QWT的Qt4版本,它使用libQtGui.so.4
等,您可以在上面的ldd
输出中看到。与qwt-qt5
链接仅需要Qt5 so
个文件。
答案 1 :(得分:-1)
我把所有东西都换回了Qt4。厌倦了在一个不应该发生的问题上浪费时间。仍然不知道二进制结束如何链接到Qt的两个不同版本,只有当链接到Qwt时,其中Qwt仅链接到Qt5,而没有与Qwt链接的二进制文件也仅链接到Qt5。