Ask Your Question

Undefined reference to log4cxx when adding openni_camera dependency to package

asked 2013-04-12 09:16:18 -0500

tkrugg gravatar image

updated 2016-10-24 08:35:14 -0500

ngrennan gravatar image

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/ error: undefined reference to 'log4cxx::Logger::getLogger(char const*)'
/opt/ros/fuerte/stacks/openni_camera/lib/ error: undefined reference to 'log4cxx::Level::getError()'
/opt/ros/fuerte/stacks/openni_camera/lib/ error: undefined reference to 'log4cxx::Level::getWarn()'
/opt/ros/fuerte/stacks/openni_camera/lib/ error: undefined reference to 'typeinfo for log4cxx::helpers::ObjectPtrBase'
/opt/ros/fuerte/stacks/openni_camera/lib/ error: undefined reference to 'log4cxx::helpers::ObjectPtrBase::~ObjectPtrBase()'
/opt/ros/fuerte/stacks/openni_camera/lib/ 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/

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-08-26 06:55:38 -0500

Throst Gunnulf gravatar image

updated 2013-08-26 06:58:25 -0500

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-04-12 09:16:18 -0500

Seen: 1,478 times

Last updated: Aug 26 '13