V
V
vipermagi2017-05-04 06:57:57
linux
vipermagi, 2017-05-04 06:57:57

How to make g++ portable cross compiler?

I am making an appimage image of a tulsa with a cross compiler inside. Every time the image is run, it mounts itself to a random path. And when you try to run from within the g++ crosscompiler image, it gives an error, such a file does not exist.
The bottom line is that the /fixed/path/devkit-x86/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2 dependency is embedded inside the g++ cross-compiler binary and when transferred to an environment where this file in a place that doesn't match the hardcoded path, g++ "doesn't find itself".
If you write something like patchelf --set-interpreter /new/path/devkit-x86/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2 g++ , then g++ will work again, before packing into an image. But the image is mounted read-only and I can’t solve this problem like that.
I also tried this trick: g++ -Wl,-dynamic-linker,/new/path/devkit-x86/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2 , but it didn't help.
How to be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vipermagi, 2017-05-15
@vipermagi

In general, such a not very universal crutch became the solution to the problem.
Inside the already created image, there is an AppRun launcher in which I registered immediately after mounting to find out the current directory like this:

HERE=$(dirname $(readlink -f "${0}"))
export MYAPP_DIR="${HERE}/opt/myApp"

then create a symlink in /tmp :
mkdir -p "/tmp/myApp.AppImage/lib64"
ln -sf ${MYAPP_DIR}/devkit-x86/sysroots/x86_64-pokysdk-linux/lib/ld-2.20.so /tmp/myApp.AppImage/lib64/ld-linux-x86-64.so.2

And in the script that creates the image, I patch the paths to the speaker loader in all all cross compiler binaries like this:
To whom it will be interesting, I put the cross-compiler for Intel Edison into the AppImage image. There are two subdirectories in the Edison toolchain directory: the sysroot directory with files and libraries of the target architecture; cross-compiler directory for the architecture on which cross-compilation occurs. Due to the fact that there are different directories, as well as the fact that the cross-compiler is not already assembled by me and I have no desire with time for re-cutting, the methods proposed by jcmvbkbc are not suitable. That's why I leave the compiler as it is and use this crutch.

J
jcmvbkbc, 2017-05-04
@jcmvbkbc

From the description it is not entirely clear who does not detect whom.
For completeness, please provide the full text of the error and the output of the command g++ -v.
If the compiler can't find your sysroot try running it like this:

g++ --sysroot=/new/path/devkit-x86/sysroots/x86_64-pokysdk-linux

A more complete solution to this problem is to configure gcc with the --with-sysroot option to point inside the directory specified by --prefix. In this case, the sysroot will be found even when moving the entire installation. See https://gcc.gnu.org/install/configure.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question