0
$\begingroup$

Rosanswers logo

Hi. I have written a C++ program, which goes by the name:

listener.cpp

located in:

/home/user/catkin_ws/src/project1/src/listener.cpp

Which works fine, but is unable to import one .h file:

    #include "ros/ros.h"
    #include "std_msgs/String.h"
    #include "std_msgs/Int8.h" 
//#include <sound_play/sound_play.h>
    #include <unistd.h>

Without the sound_play line, it works, and the program does what is expected. But i am needing to make use of sound_play. This is the catkin_make output when running it without commenting the line:

[100%] Building CXX object project1/CMakeFiles/project1.dir/src/listener.cpp.o
/home/user/catkin_ws/src/project1/src/listener.cpp:4:35: fatal error: sound_play/sound_play.h: No such file or directory
compilation terminated.

I do have installed audio_common, and already catkin_make'd it. It is located in:

/opt/ros/groovy/stacks/

And the terminal is "sourced" with:

source catkin_ws/devel/setup.sh

I've tried (for testing purposes) to import other things, and it seems like it only allows you to import things that are in the opt/ros/share folder. By the way, what i want to do with sound_play is more or less like documented here: test.cpp for sound_play

How may I include sound_play package? Any help is welcomed, as I think i am not coping with the include and dependency system yet. Greetings ROS community.

EDIT: So after some answers, i decided to build with rosmake, and i followed more or less the listener talker tutorial. I created a package with the same dependencies, except for adding sound_play Whenever i build, it throws an error, because it cannot use ros.h properly:

Linking CXX executable ../bin/talker
  CMakeFiles/talker.dir/src/talker.cpp.o: In function `ros::Publisher ros::NodeHandle::advertise<std_msgs::String_<std::allocator<void> > >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, bool)':
  /opt/ros/groovy/include/ros/node_handle.h:241: undefined reference to `ros::NodeHandle::advertise(ros::AdvertiseOptions&)'
  CMakeFiles/talker.dir/src/talker.cpp.o: In function `void ros::Publisher::publish<std_msgs::String_<std::allocator<void> > >(std_msgs::String_<std::allocator<void> > const&) const':
  /opt/ros/groovy/include/ros/publisher.h:106: undefined reference to `ros::Publisher::Impl::isValid() const'
  /opt/ros/groovy/include/ros/publisher.h:118: undefined reference to `ros::Publisher::publish(boost::function<ros::SerializedMessage ()> const&, ros::SerializedMessage&) const'
  CMakeFiles/talker.dir/src/talker.cpp.o: In function `main':
  /home/aimc/catkin_ws/src/include_test/src/talker.cpp:21: undefined reference to `ros::init(int&, char**, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
  /home/aimc/catkin_ws/src/include_test/src/talker.cpp:28: undefined reference to `ros::NodeHandle::NodeHandle(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)'
  /home/aimc/catkin_ws/src/include_test/src/talker.cpp:77: undefined reference to `ros::spinOnce()'
  /home/aimc/catkin_ws/src/include_test/src/talker.cpp:56: undefined reference to `ros::ok()'
  /home/aimc/catkin_ws/src/include_test/src/talker.cpp:84: undefined reference to `ros::Publisher::~Publisher()'
  /home/aimc/catkin_ws/src/include_test/src/talker.cpp:84: undefined reference to `ros::NodeHandle::~NodeHandle()'
  /home/aimc/catkin_ws/src/include_test/src/talker.cpp:84: undefined reference to `ros::Publisher::~Publisher()'
  /home/aimc/catkin_ws/src/include_test/src/talker.cpp:84: undefined reference to `ros::NodeHandle::~NodeHandle()'
  collect2: ld returned 1 exit status
  make[3]: *** [../bin/talker] Error 1
  make[3]: Leaving directory `/home/aimc/catkin_ws/src/include_test/build'
  make[2]: *** [CMakeFiles/talker.dir/all] Error 2
  make[2]: Leaving directory `/home/aimc/catkin_ws/src/include_test/build'
  make[1]: *** [all] Error 2
  make[1]: Leaving directory `/home/aimc/catkin_ws/src/include_test/build'
-------------------------------------------------------------------------------}
[ rosmake ] Output from build of package include_test written to:
[ rosmake ]    /home/aimc/.ros/rosmake/rosmake_output-20130314-002400/include_test/build_output.log
[rosmake-2] Finished <<< include_test [FAIL] [ 4.25 seconds ]                                                                              
[ rosmake ] Halting due to failure in package include_test. 
[ rosmake ] Waiting for other threads to complete.                            
[ rosmake ] Results:                                                                                                                       
[ rosmake ] Built 25 packages with 1 failures.

Many thanks for any more advices to my issue. Greetings.,


Originally posted by aimc on ROS Answers with karma: 216 on 2013-03-09

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Perhaps the package is not added as dependency. Check in the /home/user/catkin_ws/src/project1/manifest.xml file -- you should have there a line like


Originally posted by Cristina with karma: 35 on 2013-03-10

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by aimc on 2013-03-13:
No, i was wrong, i created a package with the sole purpose of testing this: $ catkin_create_pkg include_test rospy roscpp std_msgs sound_play

created OK, rospack says that dependencies are OK, but then catkin_make: CMake Error at /opt/ros/groovy/share/catkin/cmake/catkinConfig.cmake:71

Comment by aimc on 2013-03-13:
(find_package): Could not find a configuration file for package sound_play.

Set sound_play_DIR to the directory containing a CMake configuration file for sound_play. The file will have one of the following names:

sound_playConfig.cmake
sound_play-config.cmake
$\endgroup$
0
$\begingroup$

Rosanswers logo

I ended up solving this include problem with the following:

  • Everything messed up so i reinstalled ROS (I was incapable of even running begginer_tutorials)

  • I reinstalled basic componentes needed, sound_play for example: sound_play which is part of audio-common

  • I copied some ".h" files to the "include" folder of my project. In particular: "sound_play/sound_play.h" and "sound_play/soundRequest.h"

The third one ended up solving everything. This may be a workaround but works great. Hope this helps.


Originally posted by aimc with karma: 216 on 2013-03-15

This answer was ACCEPTED on the original site

Post score: -1

$\endgroup$

Your Answer

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