I understand the basic concept of using a cross compiler to compile code on one architecture and then copying the executable to another architecture to run it. But I can't figure out the last step of the typical ./configure; make; make install sequence in the context of cross compiling.

For example, I want to cross-compile libusb for an ARM device using my Ubuntu PC. I downloaded the libusb source code, ran configure and make:

> ./configure --disable-udev --host=arm-linux-gnueabihf CC=/usr/bin/arm-linux-gnueabi-gcc
> make

At this point, I have a bunch of libusb compiled binaries for the ARM architecture. Ideally, I want to copy those binaries over to the ARM device and run make install so that I don't have to manually copy them into their destination directories. But that would mean I'd have to copy over the entire build environment from the Ubuntu computer, which seems like a waste of time and disk space. Or I could gather just the binaries and the appropriate Makefiles and copy them over, but that seems clunky.

Is there a more elegant way to take advantage of make install on the destination architecture?

2 Answers 2


Yes, at least for Autotools-based build systems, as used here (and probably some others); these support a DESTDIR variable which can be used to install somewhere other than /.

mkdir destdir
make DESTDIR="${PWD}/destdir" install

This will give you the target binaries (and accompanying files) in destdir; you can then copy that to the target device's /.

  • So I would never run make on the destination computer. Just copy the directory of binaries over to the destination computer and do one big copy to /?
    – Dan Laks
    Commented Dec 8, 2016 at 2:32
  • Yes, that's it! Commented Dec 8, 2016 at 2:34

OK, As @Stephen Kitt mentioned you can pass DESTDIR to make install. Here I will provide one more possible option you can try,

  • Run configure script with --prefix=/your/custom/install/dir/path

You can pass --prefix along with your custom path to configure script. So that whenever you run make install it will install to the prefix directory.


./configure --disable-udev --host=arm-linux-gnueabihf CC=/usr/bin/arm-linux-gnueabi-gcc --prefix=/your/custom/path
  • Run make install with DESTDIR

make install supports DESTDIR variable which will be prepended to installed target file.


make DESTDIR=`pwd`/DESTDIR install
  • When you specify --prefix, you need to use the target directory that you want to use on the target system; you can't use --prefix to install somewhere handy that's not the real installation directory. (Well, you can in some cases, but you can't rely on that.) Commented Dec 9, 2016 at 10:57
  • @StephenKitt Well, It completely depends on the build rules but most of the standard packages will have the support. At least it is recommended to use standard Directory Variables. For instance, bindir will have /prefix/bin/*
    – Thushi
    Commented Dec 9, 2016 at 12:01
  • I agree --prefix is widely supported; what I'm saying is it's not intended for the use you're putting it to here (unless I'm misunderstanding your intentions). DESTDIR is designed for the kinds of scenarios the OP is interested in. Commented Dec 9, 2016 at 12:15
  • @StephenKitt : Nod :)
    – Thushi
    Commented Dec 20, 2016 at 5:47
  • The distinction between target and staging prefix is crucial when cross-compiling. For example libcrypto from OpenSSL uses prefix to access certificates and engine data at runtime. You can see that the actual prefix paths are compiled into the binary.
    – marski
    Commented Jan 10, 2022 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .