Add Ros library to qt creator

asked 2015-04-16 12:05:29 -0500

anil gravatar image

Hi everybody

I want to use qt gui with ros. I follow this steps.

Create qt and ros project different workspace.I organized Cmakelist.txt for creating .so file and add this lines

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 )

Then libbase.so file was created. I add libbase.so file to Qt project by using external library ,and ı preapered the code. when ı try to run the qt project ı have ros undifed references errors.

    /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.
edit retag flag offensive close merge delete

Comments

1

Hi, i not complete get your exact question, do u want to use qtcreator to build ros? and then add your Base as a Lib to use it in other ROS-Packages? What Version of ROS you are using? seems not to be catkin already or?

ReneGaertner gravatar image ReneGaertner  ( 2015-04-17 03:54:49 -0500 )edit

Firstly thank for interest. I am using ROS indigo and want to use qt creator gui to build ROS project. And Base.cpp as a Lib (Libbase.so name) to use under qt gui. Briefly ı have some parameters in ROS project then then I want to assign parameters in qt gui (with the set and get functions in Base)

anil gravatar image anil  ( 2015-04-17 16:09:51 -0500 )edit

@anil did you ever fix this? I think I'm trying to do something very similar

JaneSheard gravatar image JaneSheard  ( 2016-04-21 05:17:12 -0500 )edit