Rosanswers logo

Hi, I've been struggling with this for a few hours. I created a package depending on openni, openni_camera and openni_launch.

My problem is: on compilation, i'm getting

Linking CXX executable ../bin/listener
/opt/ros/fuerte/stacks/openni_camera/lib/libopenni_nodelet.so: error: undefined reference to 'log4cxx::Logger::getLogger(char const*)'
/opt/ros/fuerte/stacks/openni_camera/lib/libopenni_nodelet.so: error: undefined reference to 'log4cxx::Level::getError()'
/opt/ros/fuerte/stacks/openni_camera/lib/libopenni_nodelet.so: error: undefined reference to 'log4cxx::Level::getWarn()'
/opt/ros/fuerte/stacks/openni_camera/lib/libopenni_nodelet.so: error: undefined reference to 'typeinfo for log4cxx::helpers::ObjectPtrBase'
/opt/ros/fuerte/stacks/openni_camera/lib/libopenni_nodelet.so: error: undefined reference to 'log4cxx::helpers::ObjectPtrBase::~ObjectPtrBase()'
/opt/ros/fuerte/stacks/openni_camera/lib/libopenni_nodelet.so: error: undefined reference to 'log4cxx::Level::getFatal()'

I thought it was whining about the fact that I didn't link the log4cxx library on compilation. So I added this in CMakeLists.txt

rosbuild_add_library(${PROJECT_NAME} /usr/lib/liblog4cxx.so)

but it didn't change much. Then I tried the answer from another question (which I'm not allowed to mention giving my baby karma) suggesting to use target_link_libraries() but I couldn't use it successfully.

Any ideas? NB: I'm running fuerte on ubuntu 12.04. Thanks for your help

Originally posted by tkrugg on ROS Answers with karma: 1 on 2013-04-12

Post score: 0


1 Answer 1


Rosanswers logo

Hey, I don't know if this is still useful, but I just solved a similar problem. In any case, I'll leave my solution here.

What I did was to add the following line to the begginning of my CMakeLists.txt.


What this does is link every executable to the log4cxx library.

Keep in mind that link_libraries() is deprecated, so if this problem only occurs with one executable, it is preferred to use target_link_libraries(). I did not use this because the errors occurred in every executable, so link_libraries() was an easier solution.

If this does not solve your problem, don't hesitate in asking me for help, I'll try my best to help you solve the problem.

Originally posted by Throst Gunnulf with karma: 56 on 2013-08-26

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

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