To simplify the sysroot generation for cross compiling, I generate a tar file with relative symbolic links.
If I print the tar context with
tar tvf sysroot-libc6-dev.tar
then I get the correct result:
lrw-r--r-- jens/jens 1 2018-03-30 23:42 usr/lib/x86_64-linux-gnu/libBrokenLocale.so -> ../../../lib/x86_64-linux-gnu/libBrokenLocale.so.1
lrw-r--r-- jens/jens 1 2018-03-30 23:42 usr/lib/x86_64-linux-gnu/libanl.so -> ../../../lib/x86_64-linux-gnu/libanl.so.1
lrw-r--r-- jens/jens 1 2018-03-30 23:42 usr/lib/x86_64-linux-gnu/libcidn.so -> ../../../lib/x86_64-linux-gnu/libcidn.so.1
If I unpack the tar archive with
tar xvf sysroot-libc6-dev.tar
then the symlinks are absolute, this is a mess, because then the sysroot directory points to my host machine and cross compile will not work.
ls -al
lrwxrwxrwx 1 jens jens 33 Jan 14 11:39 libanl.so -> /lib/x86_64-linux-gnu/libanl.so.1
lrwxrwxrwx 1 jens jens 42 Jan 14 11:39 libBrokenLocale.so -> /lib/x86_64-linux-gnu/libBrokenLocale.so.1
lrwxrwxrwx 1 jens jens 34 Jan 14 11:39 libcidn.so -> /lib/x86_64-linux-gnu/libcidn.so.1
The purpose of the script is to keep everything relative, also the linker scripts, e.g. libc.so will be patched to relative links.
Thanks in advance
Jens Riebold
I found the problem of my post. The tar will set relative links only if the destination of the symbolic link is also in the tar archive.
The problem with cross compiling for the raspberry pi are the absolute symbolic links to the libraries and the absolute paths in the ld scripts. (SO Files).
If you copy prebuild libraries from the raspberry pi into your cross compile project, then you have to fix that. It took me some time to understand the strange linker issues while working on my project.
The project works as follows:
The output is a tar file with relative links and relative pathes in the ld scripts.
Example:
Output: