# getting a C++ Programm run under ROS

hi Im trying to write a RTSP Client for ROS and found live555.com site and there openRTSP / testRTSPClient wich are command line tools that already do what i want. So i thought should not be to hard get that running in ROS. So I created a new package and ctrl+C/V the main file in the src folder and the rest in the Include folder when i try to Compile it now it does not find all the headers. and im dont know how to tell ROS where it should look for all the .hh files.

I tryed adding them in the Cmakelist.txt file with add_subdirectory and include_directories bot it did not work.

So my next try was to move all .cpp and .hh files from all folders/subfolders into the src folder and now I get "undefined reference to" errors for all funktions

I started with ROS a week ago so maybe its some basic thing i missed in the tutorials.

would be nice if someone could help me

EDIT:

that testRTSP .cpp is a Command line tool wich depends on some librarys and allows me to access an rtps- stream. so my plan was to send that stream over a image pipeline to openCV. but i have no idea what i need to change to compile that code with rosmake.

So i have my src/maintest.cpp file wich includes livemedia.hh livemedia.hh is located at ../livemedia/include/livemedia.hh

livemedia itself creates a liblivemedia.a file when compiled.

So do i have to make a livemedia ros package first so it creates a libary? when yes how do i create a library.

edit retag close merge delete

You need to be more explicit about what exactly you did and what exactly your errors are as a result of every step.

( 2013-04-19 00:57:54 -0500 )edit

Sort by » oldest newest most voted
1. Create a Package: http://www.ros.org/wiki/ROS/Tutorials/CreatingPackage
2. go in the CMakeLists.txt and add following line:

PCL is only an example Library. Make sure that your cpp file is placed in src/..

The last step is only to call rosmake [pkg-name]

more

thx for your answer but it did not help. im editing my post and make it more specific

( 2013-04-19 01:55:01 -0500 )edit

You are supposed to put all .cpp files into src/ and the headers to include/mypackagename/

If you are lazy and your headers are not needed from the outside, you can also put them in the src folder. Then you can include them as #include "myclass.h" instead of #include <mypackagename/myclass.h>

The undefined reference error is from the linker, which doesn't know where the executable code for the functionality defined in the headers is. This means you either didn't specify a required library or didn't compile all your code.

For the former see Waterplants answer, for the latter make sure you add all your .cpp files to the rosbuild_add_executable command in CMakeLists.txt, e.g.

rosbuild_add_executable (programname src/main.cpp src/somethingelse.cpp src/myclass.cpp)

more

already tryed to put all .cpp and .hh files in the src folder but did not work . how do i specify the linker where it finds all the code. what you mean with library? all i use is roscpp as i just have cpp files

( 2013-04-19 02:34:50 -0500 )edit

( 2013-04-19 05:41:05 -0500 )edit