Which path should I pass to the --prefix
option when doing cross compiling: should I specify the path on my build machine or the path on the target platform?
Suppose I build the code into /home/me/arm/build/target_fs/usr
, after that I copy the files into my target platform where they will be located at /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 the --prefix
is not the path for build but the path for running environment (i.e. the path on target platform). The answers here makes me think that I'm right. But there are many pages out there (for example, Cross-compiling FFmpeg for Raspbian: --prefix=/my/path/were/i/keep/built/
) where people use the path on build machine for the --prefix
. So I'm confused.
To cross-compile is to build on one platform a binary that will run on another platform. When speaking of cross-compilation, it is important to distinguish between the build platform on which the compilation is performed, and the host platform on which the resulting executable is expected to run.
"building a cross-compiler is significantly harder than building a compiler that targets the platform it runs on." The problem exists due to the way libraries are built and accessed. In the normal situation all the libraries are located in a specific spot, and are used by all apps on that system.
A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a PC but generates code that runs on an Android smartphone is a cross compiler.
Yes you are right, --prefix is the path for working environment. Just use --prefix=/usr. You can check in which folder path make install command will install your binary by installing in DESTDIR. For example if you use --prefix=/usr and make install 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 run make install, then the binary will be installed in your prefix i.e. in "/usr".
As you are cross-compiling, I think it doesn't matter which prefix you use, because anyways you will be installing in DESTDIR and then copying the binary files manually to your target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With