0
$\begingroup$

Rosanswers logo

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.


Originally posted by Stiebi on ROS Answers with karma: 21 on 2013-04-19

Post score: 0


Original comments

Comment by dornhege on 2013-04-19:
You need to be more explicit about what exactly you did and what exactly your errors are as a result of every step.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

  1. Create a Package: http://www.ros.org/wiki/ROS/Tutorials/CreatingPackage

  2. go in the CMakeLists.txt and add following line:

    rosbuild_add_executable (example src/example.cpp) target_link_libraries(example ${PCL_LIBRARIES})

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]


Originally posted by Waterplant with karma: 90 on 2013-04-19

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Stiebi on 2013-04-19:
thx for your answer but it did not help. im editing my post and make it more specific

$\endgroup$
0
$\begingroup$

Rosanswers logo

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) 

Originally posted by Felix Endres with karma: 6468 on 2013-04-19

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Stiebi on 2013-04-19:
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

Comment by Felix Endres on 2013-04-19:
Can you please post the content of your CMakeLists.txt

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.