简体   繁体   中英

configure “--prefix” option for cross compiling

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 (ie 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.

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 ie 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.

As you may found:

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

As far as I understand you are trying to compile a compiler for some target.

In this case prefix will specify directory when the compiler will be installed after make install command on build machine. After it you can take a compiler there.

. 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?

In your case prefix command have no sense. Because you are copy binaries by hands.

Also you can find all other info on GCC official site: https://gcc.gnu.org/install/finalinstall.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM