I want to cross-compile C++-applications for the raspi using the rpi-tools, CMake and a raspbian sysroot I'm exporting via nfs from a running raspi. My CMake-toolchain-file is OK, header-files and most of the libraries are correctly detecting inside my sysroot-mount.

Except that there is one issue which seems to be new with raspbian stretch?

The problem I'm facing is that the some library-files located at /usr/lib/arm-linux-gnueabihf/ are a link to the real file located at /lib/arm-linux-gnueabihf/. This link is done with an absolute path.

This is a problem when using the sysroot-mount via NFS (my moint-point is /mnt/rpi-rootfs). But this will also be a problem when doing cross-compilation with a copy of sysroot if sysroot contains links like that.

My CMakeFiles are looking for rt for example and as librt is linked to /lib/arm-linux-gnueabihf/librt.so.1. This file does not exist (it is actually located in /mnt/rpi-rootfs/lib/arm-linux-gnueabihf/librt.so.1) cmake fails.

Where is my mistake? Is there something I can do with the raspbian-distribution? Is this a bug? Is it a feature?

up vote 0 down vote accepted

As a workaround I used symlinks to correct it:

cd /usr/lib/arm-linux-gnueabihf
symlinks -c .

absolute: /usr/lib/arm-linux-gnueabihf/libanl.so -> /lib/arm-linux-gnueabihf/libanl.so.1
changed:  /usr/lib/arm-linux-gnueabihf/libanl.so -> ../../../lib/arm-linux-gnueabihf/libanl.so.1
[..]

Previous answer: realpath doesn't work as expected, it adds a ../ too much.

I created a small script which replaces absolute links with relative ones in the current-directory.

#!/bin/bash

for L in $(find -type l)
do
    ABSOLUTE=$(readlink $L)

    if [[ $ABSOLUTE =~ ^/ ]] # if it starts with a / it is an absolute link
    then
        RELATIVE=$(realpath --relative-to=$L -s $ABSOLUTE)
        echo fixing link of $L to $ABSOLUTE with $RELATIVE
        sudo ln -sf $RELATIVE $L
    fi
done

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.