Home | Tutorials | Wiki | Issues
Ask Your Question
0

ERROR: undifined reference to sensors

asked 2015-11-09 12:10:53 -0500

huub8 gravatar image

For a project I'm working on I needed to not use the default way of installing but instead I manually installed all of the dependencies in: https://github.com/osrf/homebrew-simu...

I tried making and installing it by:

cmake -DENABLE_TESTS_COMPILATION:BOOL=False ../gazebo
make -j4 install

But this causes the following errors as a result of the make command:

../gazebo/physics/libgazebo_physics.so.6.1.0: undefined reference to `gazebo::sensors::SensorManager::~SensorManager()'
../gazebo/physics/libgazebo_physics.so.6.1.0: undefined reference to `gazebo::sensors::get_sensor(std::string const&)'
../gazebo/physics/libgazebo_physics.so.6.1.0: undefined reference to `gazebo::sensors::Sensor::FillMsg(gazebo::msgs::Sensor&)'
../gazebo/physics/libgazebo_physics.so.6.1.0: undefined reference to `gazebo::sensors::SensorManager::SensorManager()'
../gazebo/physics/libgazebo_physics.so.6.1.0: undefined reference to `gazebo::sensors::create_sensor(boost::shared_ptr<sdf::Element>, std::string const&, std::string const&, unsigned int)'
../gazebo/physics/libgazebo_physics.so.6.1.0: undefined reference to `gazebo::sensors::SensorManager::ResetLastUpdateTimes()'
../gazebo/physics/libgazebo_physics.so.6.1.0: undefined reference to `gazebo::sensors::remove_sensor(std::string const&)'
../gazebo/physics/libgazebo_physics.so.6.1.0: undefined reference to `gazebo::sensors::SensorManager::SensorsInitialized()'
collect2: error: ld returned 1 exit status
make[2]: *** [tools/gz-6.1.0] Error 1
make[1]: *** [tools/CMakeFiles/gz.dir/all] Error 2
make: *** [all] Error 2

I'm pretty much new to linux and can't find why this linking goes wrong.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-11-18 08:46:44 -0500

plim gravatar image

Add gazebo_sensors to target_link_libraries for your executable. The problem in detail is described in Issue #1516

edit flag offensive delete link more
0

answered 2016-10-07 11:04:56 -0500

ElizabethA gravatar image

updated 2016-10-07 15:22:08 -0500

-------------------Real Answer-------------------

I hit your error when I'm trying to use physics::World stuff. I got around it by adding

set_target_properties(target_name PROPERTIES LINK_FLAGS "-Wl,--no-as-needed")

to my CMakeLists, where target_name is the name I give the executable in add_executable(target_name path_to_cpp_file)

I found the set_target_properties stuff from a post here: https://bitbucket.org/osrf/gazebo/iss...

-------------------Initial answer-------------------

Not sure if this will work, depending on your version of Gazebo, etc., but I'm on Gazebo 2.2, and had a similar error with gazebo::transport and gazebo::world stuff. I had to edit my CMakeLists to include the GAZEBO_..._DIRS stuff.

The "Compiling The PlugIn" section of this page helped a LOT: http://gazebosim.org/tutorials/?tut=p...

Things got better once I added the following to my CMakeLists:

find_package(gazebo REQUIRED)

include_directories(${GAZEBO_INCLUDE_DIRS})

link_directories(${GAZEBO_LIBRARY_DIRS})

list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")

target_link_libraries(hello_world ${GAZEBO_LIBRARIES})

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-11-09 12:10:53 -0500

Seen: 2,245 times

Last updated: Oct 07 '16