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

Error while cross-compiling rospkg for arm

asked 2015-04-22 04:56:41 -0500

Alice63 gravatar image

Hello,I want to cross compile rospackage for arm.I do following the website http://answers.ros.org/question/19107... . I have created rostoolchain.cmake file like this:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rostoolchain.cmake)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-linux-gcc)
set(CMAKE_CXX_COMPILER /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-linux-g++)
set(CMAKE_FIND_ROOT_PATH /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain)
set(CMAKE_LIBRARY_PATH /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/lib /home/znzx/boost/lib /opt/ros/hydro/lib)
set(CMAKE_INCLUDE_PATH  /home/znzx/boost/include /opt/ros/hydro/include /usr/include) 
set(BOOST_LIBRARY  /home/znzx/boost/lib)
set(BOOST_INCLUDE  /home/znzx/boost/include)
set(BOOST_ROOT /home/znzx/boost)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

When I excute $./src/catkin/bin/catkin_make_isolated -DCMAKE_TOOLCHAIN_FILE=/home/znzx/catkin_ws/src/rostoolchain.cmake I got the following errors:

-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Found gtest sources under '/usr/src/gtest': gtests will be built
CMake Error at cmake/assert.cmake:17 (message):


  Assertion failed: check for file existence, but filename
  (RT_LIBRARY-NOTFOUND) unset.  Message: RT Library

Call Stack (most recent call first):
  cmake/tools/rt.cmake:42 (assert_file_exists)
  cmake/all.cmake:148 (include)
  CMakeLists.txt:8 (include)


-- Configuring incomplete, errors occurred!
<== Failed to process package 'catkin': 
  Command 'cmake /home/znzx/ros_catkin_ws/src/catkin -DCATKIN_DEVEL_PREFIX=/home/znzx/ros_catkin_ws/devel_isolated/catkin -DCMAKE_INSTALL_PREFIX=/home/znzx/ros_catkin_ws/install_isolated -DCMAKE_TOOLCHAIN_FILE=/home/znzx/catkin_ws/src/rostoolchain.cmake' returned non-zero exit status 1

Reproduce this error by running:
==> cd /home/znzx/ros_catkin_ws/build_isolated/catkin && cmake /home/znzx/ros_catkin_ws/src/catkin -DCATKIN_DEVEL_PREFIX=/home/znzx/ros_catkin_ws/devel_isolated/catkin -DCMAKE_INSTALL_PREFIX=/home/znzx/ros_catkin_ws/install_isolated -DCMAKE_TOOLCHAIN_FILE=/home/znzx/catkin_ws/src/rostoolchain.cmake

Command failed, exiting.

What is RT library? How can I do to solve the problem? Please help me.thank you very much

edit retag flag offensive close merge delete

Comments

I'v got exactly the same problem. Did you solve it in the meantime?

inspire gravatar image inspire  ( 2017-01-20 06:22:12 -0500 )edit

Did you ever figure this out? I'm hitting the same problem.

jkolb gravatar image jkolb  ( 2017-08-23 09:53:13 -0500 )edit

The same error...

taogashi gravatar image taogashi  ( 2017-11-13 22:55:16 -0500 )edit

I am also seeing this for certain build structures. It seems to be a non-deterministic catkin issue not related to the CMake, but somehow related to the topology.

pbeeson gravatar image pbeeson  ( 2018-01-20 13:32:04 -0500 )edit

Similar error here. Did someone solve the problem? I think it might be related to this pull request: https://github.com/ros/catkin/pull/811 .

mateus-amarante gravatar image mateus-amarante  ( 2018-02-01 10:50:35 -0500 )edit

Does your rootfs provide an librt.so? If so, where?

antipattern gravatar image antipattern  ( 2018-02-06 08:02:05 -0500 )edit

In my case, the librt.so is in ${CMAKE_FIND_ROOT_PATH}/lib/arm-linux-gnueabihf/. When I add link_directories(${CMAKE_FIND_ROOT_PATH}/usr/lib/arm-linux-gnueabihf) (the file is there), I still get the same error.

mateus-amarante gravatar image mateus-amarante  ( 2018-02-06 18:23:57 -0500 )edit

Then I am lost, I thought your toolchain might not include the multiarch dirs by itself, but if you add them manually it should work. Does crosscompiling a regular CMake project which links against librt work with your toolchain?

antipattern gravatar image antipattern  ( 2018-02-07 06:31:23 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2018-03-21 11:39:45 -0500

I came up with a temporary solution. My target device is a BeagleBone Black.

1) You need to create a simple toolchain.cmake file like the following one

# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)

# Set the target architecture
set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)

# specify the cross compiler
SET(CMAKE_C_COMPILER   /usr/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)

# where is the target environment 
SET(CMAKE_FIND_ROOT_PATH "/path/to/target-root") # no slash "/" at the end

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Set compiler flag
SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}" )

2) Setup your catkin profile. Let's suppose you want to create a profile called "cross" and the toolchain.cmake file is located in src folder.

catkin config --profile cross --extend /path/to/target-root/opt/ros/kinetic
catkin config --profile cross --cmake-args  -DCMAKE_TOOLCHAIN_FILE=`pwd`/src/toolchain.cmake

It's also good to set an specific location for "build", "devel" and "install" folders.

3) In the CMakeLists.txt of your project, place the following code before you link your targets to catkin_LIBRARIES:

if(CMAKE_CROSSCOMPILING) 
    set(fixed_catkin_libraries)
    foreach (dir ${catkin_LIBRARIES})
        foreach(root_path ${CMAKE_FIND_ROOT_PATH})
            if(dir MATCHES "^${root_path}/") # assume CMAKE_FIND_ROOT_PATH has no "/" at the end
                list(APPEND fixed_catkin_libraries ${dir})
            else()
                list(APPEND fixed_catkin_libraries "${root_path}${dir}")
            endif()
        endforeach()
    endforeach()
    set(catkin_LIBRARIES ${fixed_catkin_libraries})
endif()

**4) Compile your project. If you get errors, try running touch src/toolchain.cmake

References:

[1] https://cmake.org/Wiki/CMake_Cross_Co...

[2] https://github.com/AutoModelCar/catki...

[3] https://github.com/ros/catkin/pull/811

edit flag offensive delete link more
0

answered 2018-02-06 07:29:23 -0500

antipattern gravatar image

Currently, the support for crosscompiling ROS is limited. You will encounter multiple packages where you need to adapt the buildprocess, such that hard-coded paths don't get populated to the cmake configuration files.

The specific error you're having might be related to the fact, that you have testing enabled ('-- Found gtest sources under '/usr/src/gtest': gtests will be built'). In my crosscompiled builds this lead to failure because paths on the host system where being included. Note that this was a year ago, the behavior might have changed since then.

However, enabling the tests does not make sense in a crosscompiled build anyway, since you can't test the binaries on the build-platform.

In order to disable the tests, pass or set CATKIN_ENABLE_TESTING=Off.

edit flag offensive delete link more

Comments

After some research I don't think this is causing the problem, it might cause issues later on, though.

antipattern gravatar image antipattern  ( 2018-02-06 08:01:00 -0500 )edit

Following CMake Cross Compilling tutorial is not enough to compile a ROS package?

mateus-amarante gravatar image mateus-amarante  ( 2018-02-06 18:29:23 -0500 )edit

Unfortunately not. Some ROS packages don't follow CMake conventions strictly and pollute include-/link-dirs with host-paths. Also, the generated CMake configs contain paths to the host filesystem which need to be santicized manually. There is a catkin PR which aims to fix this.

antipattern gravatar image antipattern  ( 2018-02-07 06:35:46 -0500 )edit

Question Tools

4 followers

Stats

Asked: 2015-04-22 04:56:41 -0500

Seen: 3,685 times

Last updated: Mar 21 '18