Configure the --prefix option for cross-compiling

Which path should be passed to the --prefix parameter when doing cross-compilation: should I specify a path on my build machine or a path on the target platform?

Suppose I create code in /home/me/arm/build/target_fs/usr , and then copy the files to my target platform, where they will be located in /usr . Should I use --prefix=/home/me/arm/build/target_fs/usr or just --prefix=/usr and then make install DESTDIR=/home/me/arm/build/target_fs ?

I thought that --prefix is not a build path, but a working environment path (i.e. a path on the target platform). The answers here make me think I'm right. But there are many pages (e.g. Cross-compiling FFmpeg for Raspbian : --prefix=/my/path/were/i/keep/built/ ), where people use the path on the build machine for --prefix . Therefore, I am confused.

+5
source share
2 answers

Yes, you're right, --prefix is โ€‹โ€‹the way to work. Just use --prefix = / usr. You can check in which folder the make install install path will install your binary by setting to DESTDIR. For example, if you use --prefix = / usr and set DESTDIR = / home / me / arm / build / target_fs, then the binaries will be installed in the folder / home / me / arm / build / target _fs / usr. And if you just ran make install, then the binary will be installed in your prefix, that is, in "/ usr".

Since you are doing cross-compilation, I think it doesnโ€™t matter which prefix you use, because in any case you will install in DESTDIR and then copy the binaries manually to your target.

+5
source

How can you find:

- prefix = dirname Specify the top-level installation directory. This is the recommended way to install tools in a directory other than the default. The default top-level installation directory is / usr / local.

As far as I understand, you are trying to compile the compiler for some purpose.

In this case, prefix will indicate the directory when the compiler will be installed after the make install on the build machine. After that you can take the compiler there.

. Should I use --prefix = / home / me / arm / build / target_fs / usr or just --prefix = / usr and then set DESTDIR = / home / me / arm / build / target_fs?

In your case, the prefix command does not make sense. Because you copy binary files by hand.

You can also find all other information on the official GCC website: https://gcc.gnu.org/install/finalinstall.html

-2
source

Source: https://habr.com/ru/post/1234768/


All Articles