Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cmake 如何在ROS中链接Qt 5.9?_Cmake_Ubuntu 14.04_Qt5_Ros_Qt5.9 - Fatal编程技术网

Cmake 如何在ROS中链接Qt 5.9?

Cmake 如何在ROS中链接Qt 5.9?,cmake,ubuntu-14.04,qt5,ros,qt5.9,Cmake,Ubuntu 14.04,Qt5,Ros,Qt5.9,以下CMakeList产生的错误如下所示: cmake_minimum_required(VERSION 2.8.12) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) project(draw_on_images) find_package(catkin REQUIRED C

以下CMakeList产生的错误如下所示:

cmake_minimum_required(VERSION 2.8.12)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

project(draw_on_images)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
)

find_package(OpenCV 2.4.8 REQUIRED)
find_package(Qt5 COMPONENTS Core Qml Quick REQUIRED)


qt5_add_resources(RESOURCES qml.qrc)

catkin_package(
  CATKIN_DEPENDS roscpp rospy std_msgs
)

include_directories(
  ${catkin_INCLUDE_DIRS}
)

add_executable(${PROJECT_NAME} ${RESOURCES} src/main.cpp src/draw_on_qimage.cpp src/provide_qpixmap_to_qml.cpp )

qt5_use_modules(${PROJECT_NAME} Core Qml Quick)

target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Qml Qt5::Quick ${OpenCV_LIBS})
我运行它的方式:

catkin_make -DCMAKE_PREFIX_PATH="/opt/Qt5.9.1/5.9.1/gcc_64/lib/" -DWITH_QT:BOOL=ON
是的,我已经找到了

错误:

Base path: /home/.../ros_workspace_test
Source space: /home/.../ros_workspace_test/src
Build space: /home/.../ros_workspace_test/build
Devel space: /home/.../ros_workspace_test/devel
Install space: /home/.../ros_workspace_test/install
####
#### Running command: "cmake /home/.../ros_workspace_test/src -DCMAKE_PREFIX_PATH=/opt/Qt5.9.1/5.9.1/gcc_64/lib/ -DWITH_QT:BOOL=ON -DCATKIN_DEVEL_PREFIX=/home/.../ros_workspace_test/devel -DCMAKE_INSTALL_PREFIX=/home/.../ros_workspace_test/install -G Unix Makefiles" in "/home/.../ros_workspace_test/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/.../ros_workspace_test/devel
-- Using CMAKE_PREFIX_PATH: /opt/Qt5.9.1/5.9.1/gcc_64/lib/
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/.../ros_workspace_test/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.19
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - draw_on_images
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'draw_on_images'
-- ==> add_subdirectory(draw_on_images)
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    WITH_QT


-- Build files have been written to: /home/.../ros_workspace_test/build
####
#### Running command: "make -j4 -l4" in "/home/.../ros_workspace_test/build"
####
[ 14%] Automoc for target draw_on_images
[ 14%] Built target draw_on_images_automoc
Linking CXX executable /home/.../ros_workspace_test/devel/lib/draw_on_images/draw_on_images
CMakeFiles/draw_on_images.dir/src/main.cpp.o: In function `int qmlRegisterType<Draw_on_qimage>(char const*, int, int, char const*)':
main.cpp:(.text._Z15qmlRegisterTypeI14Draw_on_qimageEiPKciiS2_[_Z15qmlRegisterTypeI14Draw_on_qimageEiPKciiS2_]+0x38): undefined reference to `Draw_on_qimage::staticMetaObject'
main.cpp:(.text._Z15qmlRegisterTypeI14Draw_on_qimageEiPKciiS2_[_Z15qmlRegisterTypeI14Draw_on_qimageEiPKciiS2_]+0x1b6): undefined reference to `Draw_on_qimage::staticMetaObject'
CMakeFiles/draw_on_images.dir/src/main.cpp.o: In function `Draw_on_qimage::~Draw_on_qimage()':
main.cpp:(.text._ZN14Draw_on_qimageD2Ev[_ZN14Draw_on_qimageD5Ev]+0x13): undefined reference to `vtable for Draw_on_qimage'
main.cpp:(.text._ZN14Draw_on_qimageD2Ev[_ZN14Draw_on_qimageD5Ev]+0x25): undefined reference to `vtable for Draw_on_qimage'
CMakeFiles/draw_on_images.dir/src/main.cpp.o: In function `QMetaTypeIdQObject<Draw_on_qimage*, true>::qt_metatype_id()':
main.cpp:(.text._ZN18QMetaTypeIdQObjectIP14Draw_on_qimageLb1EE14qt_metatype_idEv[_ZN18QMetaTypeIdQObjectIP14Draw_on_qimageLb1EE14qt_metatype_idEv]+0x2c): undefined reference to `Draw_on_qimage::staticMetaObject'
CMakeFiles/draw_on_images.dir/src/main.cpp.o: In function `QtPrivate::MetaObjectForType<Draw_on_qimage*, true>::value()':
main.cpp:(.text._ZN9QtPrivate17MetaObjectForTypeIP14Draw_on_qimageLb1EE5valueEv[_ZN9QtPrivate17MetaObjectForTypeIP14Draw_on_qimageLb1EE5valueEv]+0x7): undefined reference to `Draw_on_qimage::staticMetaObject'
CMakeFiles/draw_on_images.dir/src/main.cpp.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE[_ZTVN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE]+0x10): undefined reference to `Draw_on_qimage::metaObject() const'
CMakeFiles/draw_on_images.dir/src/main.cpp.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE[_ZTVN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE]+0x18): undefined reference to `Draw_on_qimage::qt_metacast(char const*)'
CMakeFiles/draw_on_images.dir/src/main.cpp.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE[_ZTVN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE]+0x20): undefined reference to `Draw_on_qimage::qt_metacall(QMetaObject::Call, int, void**)'
CMakeFiles/draw_on_images.dir/src/main.cpp.o:(.data.rel.ro._ZTIN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE[_ZTIN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE]+0x10): undefined reference to `typeinfo for Draw_on_qimage'
CMakeFiles/draw_on_images.dir/src/main.cpp.o: In function `Provide_QPixmap_to_QML::~Provide_QPixmap_to_QML()':
main.cpp:(.text._ZN22Provide_QPixmap_to_QMLD2Ev[_ZN22Provide_QPixmap_to_QMLD5Ev]+0x13): undefined reference to `vtable for Provide_QPixmap_to_QML'
main.cpp:(.text._ZN22Provide_QPixmap_to_QMLD2Ev[_ZN22Provide_QPixmap_to_QMLD5Ev]+0x25): undefined reference to `vtable for Provide_QPixmap_to_QML'
CMakeFiles/draw_on_images.dir/src/draw_on_qimage.cpp.o: In function `Draw_on_qimage::Draw_on_qimage(QQuickPaintedItem*)':
draw_on_qimage.cpp:(.text+0x4b): undefined reference to `vtable for Draw_on_qimage'
draw_on_qimage.cpp:(.text+0x5d): undefined reference to `vtable for Draw_on_qimage'
CMakeFiles/draw_on_images.dir/src/provide_qpixmap_to_qml.cpp.o: In function `Provide_QPixmap_to_QML::Provide_QPixmap_to_QML()':
provide_qpixmap_to_qml.cpp:(.text+0x52): undefined reference to `vtable for Provide_QPixmap_to_QML'
provide_qpixmap_to_qml.cpp:(.text+0x64): undefined reference to `vtable for Provide_QPixmap_to_QML'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/.../ros_workspace_test/devel/lib/draw_on_images/draw_on_images] Error 1
make[1]: *** [draw_on_images/CMakeFiles/draw_on_images.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
基本路径:/home/../ros\u工作区\u测试
源空间:/home/../ros\u workspace\u test/src
构建空间:/home/../ros\u工作空间\u测试/构建
开发空间:/home/../ros\u workspace\u test/Devel
安装空间:/home/../ros\u工作空间\u测试/安装
####
####正在运行命令:“cmake/home/../ros\u workspace\u test/src-DCMAKE\u PREFIX\u PATH=/opt/Qt5.9.1/5.9.1/gcc\u 64/lib/-DWITH\u QT:BOOL=ON-DCATKIN\u DEVEL\u PREFIX=/home/../ros\u workspace\u test/DEVEL-DCMAKE\u INSTALL\u PREFIX=/home/../ros
####
--使用CATKIN\u-DEVEL\u前缀:/home/../ros\u-workspace\u-test/DEVEL
--使用CMAKE_前缀_路径:/opt/Qt5.9.1/5.9.1/gcc_64/lib/
--使用PYTHON\u可执行文件:/usr/bin/PYTHON
--使用Debian Python包布局
--使用empy:/usr/bin/empy
--使用CATKIN\u启用\u测试:打开
--调用enable_testing()
--使用CATKIN\u测试结果\u目录:/home/../ros\u工作区\u测试/构建/测试结果
--在“/usr/src/gtest”下找到gtest源:将生成gtest
--使用Python测试:/usr/bin/nosetests-2.7
--柳絮0.6.19
--构建共享库已打开
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--~~按拓扑顺序遍历1个包:
--~~-在图像上绘制
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--+++处理柳絮包:“在图像上绘制”
--==>添加子目录(在图像上绘制)
--配置完成
--生成完成
CMake警告:
项目未使用手动指定的变量:
用QT
--生成文件已写入:/home/../ros\u工作区\u测试/生成
####
####正在运行命令“/home/../ros\u workspace\u test/build”中的“make-j4-l4”
####
[14%]用于在图像上绘制目标的Automoc
[14%]在图像上绘制内置目标
链接CXX可执行文件/home/../ros\u workspace\u test/devel/lib/draw\u on\u images/draw\u on\u images
cmakfiles/draw_on_images.dir/src/main.cpp.o:在函数“int qmlRegisterType(char const*,int,int,char const*)”中:
main.cpp:(.text.Z15qmlRegisterTypeI14Draw_uqimageipkciis2上的[uz15qmlregistertypei14draw_qimageipkciis2上的]+0x38):对“Draw_on qimage::staticMetaObject”的未定义引用
main.cpp:(.text.Z15qmlRegisterTypeI14Draw_qimageipkciis2上的_Z15qmlRegisterTypeI14Draw_qimageipkciis2上的[u Z15qmlRegisterTypeI14Draw_+0x1b6]:对“Draw__qimage::staticMetaObject”的未定义引用
cmakfiles/draw_on_images.dir/src/main.cpp.o:在函数“draw_on_qimage::~draw_on_qimage()”中:
main.cpp:(.text._ZN14Draw_on_qimageD2Ev[_ZN14Draw_on_qimageD5Ev]+0x13):未定义对“vtable for Draw_on_qimage”的引用
main.cpp:(.text._ZN14Draw_on_qimageD2Ev[_ZN14Draw_on_qimageD5Ev]+0x25):未定义对“vtable for Draw_on_qimage”的引用
cmakfiles/draw_on_images.dir/src/main.cpp.o:在函数'QMetaTypeIdQObject::qt_metatype_id()'中:
main.cpp:(.text._zn18qMetatypeIDQoObjectip14Draw_qimagerB14qt_metatype_idEv上的[u zn18qMetatypeIDQoObjectip14Draw__qimagerB14qt_metatype_idEv]+0x2c):未定义的对“Draw_qimage::staticMetaObject”的引用
cmakfiles/draw_on_images.dir/src/main.cpp.o:在函数'QtPrivate::MetaObjectForType::value()'中:
main.cpp:(.text._ZN9QtPrivate17MetaObjectForTypeIP14Draw_qimagerb1ee5valueev[_ZN9QtPrivate17MetaObjectForTypeIP14Draw__qimagerb1ee5valueev]+0x7):对“Draw_on_qimage::staticMetaObject”的未定义引用
CMakeFiles/draw_on_images.dir/src/main.cpp.o:(.data.rel.ro."ztvn11qqqmlprivate1qqqmlelement14draw_on_qimageEE["ztvn11qqmlprivate1qqmlelement14draw_on_qimagee]+0x10]:未定义的“draw_on qimage::metaObject()常量”引用
CMakeFiles/draw_on_images.dir/src/main.cpp.o:(.data.rel.ro."ztvn11qqqmlprivate1qqqmlelement14draw_on_qimageEE["ztvn11qqmlprivate1qqqmlelement14draw_on_qimageEE]+0x18]:未定义的“draw_on qimage::qt_metacast(char const*)”
CMakeFiles/draw_on_images.dir/src/main.cpp.o:(.data.rel.ro."ztvn11qqqmlprivate1qqqmlelement14draw_on_qimageEE["ztvn11qqmlprivate1qqmlelement14draw_on_on_qimageEE]+0x20]:未定义对`在图像上绘制::qt_metacall(QMetaObject::Call,int,void**)的引用
CMakeFiles/draw_on_images.dir/src/main.cpp.o:(.data.rel.ro.ztin11qqmlprivate1qqqmlelement14draw_on_qimagee[ztin11qqmlprivate1qqqmlelement14draw_on_qimagee]+0x10):未定义对“绘制图像的类型信息”的引用
CMakeFiles/draw_on_images.dir/src/main.cpp.o:在函数'Provideqpixmap_to_QML::~ Provideqpixmap_to_QML()'中:
main.cpp:(.text._zn2提供_QPixmap_至_QMLD2Ev[_zn2提供_QPixmap_至_QMLD5Ev]+0x13):未定义对“vtable for Provide_QPixmap_至_QML”的引用
main.cpp:(.text._zn2提供_QPixmap_至_QMLD2Ev[_zn2提供_QPixmap_至_QMLD5Ev]+0x25):未定义对“vtable for Provide_QPixmap_至_QML”的引用
cmakfiles/draw_on_images.dir/src/draw_on_qimage.cpp.o:在函数“draw_on_qimage::draw_on_qimage(QQuickPaintedItem*)”中:
draw_on_qimage.cpp:(.text+0x4b):未定义对“vtable for draw_on_qimage”的引用
draw_on_qimage.cpp:(.text+0x5d):未定义对“vtable for draw_on_qimage”的引用
cmakfiles/draw_on_images.dir/src/provide_qpixmap_to_qml.cpp.o:在函数“provide_qpixmap_to_qml::provide_qpixmap_to_qml()”中:
provideqpixmap_to_qml.cpp:(.text+0x52):未定义对“vtable for provideqpixmap_to_qml”的引用
提供到qml.cpp:(.text+0x64):对“提供到qml的vtable”的未定义引用
collect2:错误:ld返回了1个退出状态
make[2]:***[/home/../ros\u workspace\u test/devel/lib/draw\u on\u images/draw\u on\u images]错误1
make[1]:***[draw_on_images/CMakeFiles/draw_on_images.dir/all]错误2
make:**[全部]错误2
调用“make-j4-l4”失败
如何在ROS中链接Qt 5.9?


我正在使用Ubuntu 14

我猜在这种情况下,CMake的AUTOMOC会失败。请参阅此处的文档 它断言,类Draw_on_qimage的头文件的名称与源文件类似,并且可以由CMake定位

您可以通过手动方式避免AUTOMOC
 QT5_WRAP_CPP(MOC_SOURCES <path of header file of your class Draw_on_qimage>)

 add_executable(${PROJECT_NAME} ${RESOURCES} src/main.cpp src/draw_on_qimage.cpp ${MOC_SOURCES} src/provide_qpixmap_to_qml.cpp 
add_executable(${PROJECT_NAME} ${RESOURCES}
                               src/main.cpp 
                               include/draw_on_images/draw_on_qimage.h src/draw_on_qimage.cpp
                               include/draw_on_images/provide_qpixmap_to_qml.h src/provide_qpixmap_to_qml.cpp)