ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

cross compile ROS fuerte: Log4cxx cmake

asked 2012-05-09 05:55:43 -0500

daniel_maier gravatar image

updated 2014-04-20 14:09:49 -0500

ngrennan gravatar image

I am trying to compile ROS Fuerte for the Nao (atom) platform but ran into some errors. I downloaded ros-underlay, created the build folder and called cmake, but it fails with:

 CMake Warning at ros_comm/tools/rosconsole/CMakeLists.txt:28 (find_package):
  Could not find module FindLog4cxx.cmake or a configuration file for package
  Log4cxx.

  Adjust CMAKE_MODULE_PATH to find FindLog4cxx.cmake or set Log4cxx_DIR to
  the directory containing a CMake configuration file for Log4cxx.  The file
  will have one of the following names:

    Log4cxxConfig.cmake
    log4cxx-config.cmake



  CMake Error at ros_comm/tools/rosconsole/CMakeLists.txt:34 (message):
  Couldn't find log4cxx library

Apparently, it is missing a log4cxx cmake config or a FindLog4cxx.cmake file. As log4cxx is a automake project, there are no cmake config files shipped with it, so where am I supposed to get that file from? In my case, I cross-compiled log4cxx, so I cannot use the system-wide installed version. Is there an easy workaround? I tried cmake-gui and set the path to the library, but it failed to find the log4cxx-includes when building rosconsole.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2012-05-09 14:32:06 -0500

Daniel Stonier gravatar image

I created a similar log4cxx-config.cmake file for cross-compiling mingw. Should be similar for what you need to do here.

set(LOG4CXX_VERSION 0.10.0)

get_filename_component(LOG4CXX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

set(LOG4CXX_INCLUDE_DIR "${LOG4CXX_CMAKE_DIR}/../../../include" CACHE FILEPATH "Log4cxx include directory")
set(LOG4CXX_INCLUDE_DIRS "${LOG4CXX_INCLUDE_DIR}")
set(LOG4CXX_LIBRARY_DIRS "${LOG4CXX_CMAKE_DIR}/../../../lib")
set(LOG4CXX_LIBRARIES "log4cxx;aprutil-1;iconv;expat;apr-1;rpcrt4;shell32;ws2_32;advapi32;kernel32;msvcrt")

I installed this into SYSROOT/share/cmake/log4cxx/log4cxx-config.cmake. The only real difference should be your library list which can be quite a bit smaller if linking to shared libraries (I was using static where you need to link to the whole chain of dependencies).

edit flag offensive delete link more

Comments

Thanks! I have my log4cxx library outside the SYSROOT directory, and placed the log4cxx-config.cmake accordingly. Yet, the rosconsole CMakeLists.txt does not respect LOG4CXX_LIBRARY_DIRS and LOG4CXX_INCLUDE_DIRS, so I added link_directories and include_directories commands. Now it compiles rosconsole.o but failes to link against log4cxx, because the -L options is missing in the linker command (using make VERBOSE=1).

daniel_maier gravatar image daniel_maier  ( 2012-05-09 23:22:46 -0500 )edit

Just curious, does your rosconsole CMakeLists.txt have this update? That was done the same time I started using the log4cxx-config above, but it is only a recent addition (03/20/12).

Daniel Stonier gravatar image Daniel Stonier  ( 2012-05-10 01:51:25 -0500 )edit

You might also want to use CMAKE_PREFIX_PATH variable to help your system find the log4cxx-config.cmake if it is outside your sysroot.

Daniel Stonier gravatar image Daniel Stonier  ( 2012-05-10 01:51:29 -0500 )edit

It has the update from your link. I tried CMAKE_PREFIX_PATH and Log4cxx_DIR, both yielding the same results. CMake seems to ignore the link_directories command.. Anyways, I find the missing include_directories, link_directories command and the missing log4cxx-config.cmake to be a bug in ROS, right?

daniel_maier gravatar image daniel_maier  ( 2012-05-10 02:23:34 -0500 )edit

log4cxx-config.cmake : that would be part of the log4cxx package (like pkgconfig), so not really ros' problem. I'd like to update eros_log4cxx later to do that properly. You're right about the LOG4CXX_LIBRARY_DIRS and LOG4CXX_INCLUDE DIRS though - it really should use that information.

Daniel Stonier gravatar image Daniel Stonier  ( 2012-05-10 02:48:29 -0500 )edit

Can you make a patch for rosconsole/CMakeLists.txt?

Daniel Stonier gravatar image Daniel Stonier  ( 2012-05-10 02:51:29 -0500 )edit
0

answered 2012-09-25 14:15:46 -0500

LeonardoLeottau gravatar image

Did you find any solution for this topic? I have the same problem. (With Ros Fuerte, Crosscompiling with NAO-atom toolchain)

Log4cxx library is not seted in the cmake project even using native compilers with cmake-gui. I have include manually the library path by using cmake-gui and it compiles. But, using the Atom cross compiling toolchain doesn´t run. I have followed instructions above and some other that I have tested without sucesfully results.

Thanks.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-05-09 05:55:43 -0500

Seen: 2,554 times

Last updated: Sep 25 '12