Product SiteDocumentation Site

19.4.2. Cross-building packages

You may find that it is too difficult to create RPMs on a given platform. It may be easier to build the RPMs on another platform, such as a Linux system, as if it were on the target platform. This is called cross-building packages, since you are building a package on one system specifically designed for another.
In most cases, the target platform is quite different from the system where you cross-build packages. Otherwise, you would likely just build the RPMs on the target platform.
The key issues with cross-building are the following:
*You must compile any executables with a cross compiler for the proper target platform.
*You must set the target platform in the RPMs you build.
*You must manage dependencies, and likely need to turn off the automatic generation of dependencies.
Setting up a cross-building environment is oftentimes more work than it is worth. If you can compile applications and build packages on the target system, do that. The cross-building option should be used only if you really cannot build packages on the target system. For example, many handheld or small-format computers lack the processor performance or memory to compile applications. These are good candidates for cross-building.
To compile executables for another platform, especially a platform with a different processor architecture, you need a cross compiler. A cross compiler runs on one system and produces executables for another.
Cross compilers are heavily used when working with embedded and small device systems. The embedded system may not have the processor power to compile applications, or it may simply be inconvenient to compile applications on the embedded system.
The Linux gcc compiler can act as a cross compiler if you install the right gcc add-on packages. See the GNU site for more on the gcc compiler.
Cross Reference
You can download GCC and other GNU software from
In addition to compiling for the target platform, you need to ensure that the RPM is marked as being for the target architecture. If not, the rpm command will fail when trying to install the RPM on the target system.
You can set the target architecture with the --target option to the rpmbuild command. For example:
rpmbuild –bi --target arm-sharp-linux
This specifies a target CPU architecture of ARM, the vendor Sharp (which just happens to make an ARM-based Linux device) and the operating system of Linux. The basic format is:
Cross Reference
See Chapter 11, Controlling the Build with rpmbuild for more on using the --target option to the rpmbuild command.
You must also turn off or correct any automatically generated dependencies in RPMs you build for other platforms. That is, any dependencies based on the operating system or architecture of the system you are cross-building on will likely not be found, or be found in a different location or format, on the target platform.
This is where the handy RPM feature of automatically building the dependencies does not work to your advantage. You can turn off this feature, however.
Cross Reference
See Chapter 18, Using RPM on Non-Red Hat Linuxes for information on how to turn off the automatic generation of dependencies.
You should turn off the automatically building of dependencies for any packages you cross build.
Using these techniques, you can build packages on one system for use on another, very different system. Due to the difficulties, you should only go this route if it becomes too difficult to use the rpmbuild command on the target systems.