我想使用qt gui和ros。我正在使用ros indigo。我按照这个步骤。
创建qt和ros项目不同的工作空间。我组织了Cmakelist.txt来创建.so文件并在ros项目中添加最后3行。
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
# Release : w/o debug symbols, w/ optimization
# RelWithDebInfo : w/ debug symbols, w/ optimization
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)
rosbuild_init()
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
#uncomment if you have defined messages
#rosbuild_genmsg()
#uncomment if you have defined services
#rosbuild_gensrv()
#common commands for building c++ executables and libraries
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
#target_link_libraries(${PROJECT_NAME} another_library)
#rosbuild_add_boost_directories()
#rosbuild_link_boost(${PROJECT_NAME} thread)
rosbuild_add_executable(run1 src/test.cpp)
add_library(base src/Base.cpp)
target_link_libraries(run1 base )
然后创建了libbase.so文件。我通过使用外部库将libbase.so文件添加到Qt项目,并且ı预先编写代码。当ı尝试运行qt项目时,有ros undifed引用错误。像这样。
/home/anil/qt_workspace/bitirme_arayuz/../../catkin_ws/src/calisma/lib//libbase.so: undefined reference to`Node::Node(float, float, double, int, int, int, int)'
/home/anil/qt_workspace/bitirme_arayuz/../../catkin_ws/src/calisma/lib//libbase.so: undefined reference to`ros::spinOnce()'
/home/anil/qt_workspace/bitirme_arayuz/../../catkin_ws/src/calisma/lib//libbase.so: undefined reference to`ros::Rate::Rate(double)'
/home/anil/qt_workspace/bitirme_arayuz/../../catkin_ws/src/calisma/lib//libbase.so: undefined reference to`ros::init(int&, char**, std::string const&, unsigned int)'
/home/anil/qt_workspace/bitirme_arayuz/../../catkin_ws/src/calisma/lib//libbase.so: undefined reference to`ros::Rate::sleep()'
/home/anil/qt_workspace/bitirme_arayuz/../../catkin_ws/src/calisma/lib//libbase.so: undefined reference to `ros::ok()'collect2: error: ld returned 1 exit status
make: *** [bitirme_arayuz] Error 118:14:16: The process "/usr/bin/make" exited with code 2. Error while building/deploying project bitirme_arayuz (kit: Desktop Qt 5.4.1 GCC 64bit) When executing step "Make" 18:14:16: Elapsed time: 00:06.
我认为Libbase.so文件是在target_link_libraries的帮助下发生的。没有ROS库。请帮忙。
感谢。