Your Search Results

    Cross-Compiling Mozilla

    For information on cross-compiling in general, see the chapter titled Cross Compilation Tools in The GNU configure and build system document.

    If you are trying to compile 32-bit Firefox on a 64-bit Linux OS, you don't need to do a full cross-compile... see these simpler instructions.

    Setting up a cross-compilation build environment

    This isn't the end-all-be-all guide to setting up a cross-compilation build environment. WFM; YMMV. (If you have to ask "where do I get... or why doesn't 'X' work", then this isn't for you.)

    For all of these examples, the following definitions are used:

    xtarget_arch name of the target system (e.g., i686-linux)
    xprefix location of cross-compilation directory heiarchy (e.g. /usr/sparc-linux)

    You should add ${xprefix}/bin to your PATH.

    Cross-compile binutils

    Download binutils and apply the binutils-cross-libpath.patch, which will make installing prebuilt libraries easier. Run configure using the following command:

    env CROSS_LIB_PATH="${xprefix}/${xtarget_arch}/lib:${xprefix}/${xtarget_arch}/usr/lib" ./configure --prefix=${xprefix} --target=${xtarget_arch}

    Build and install the package on the system.

    Install target system headers and libraries

    GCC and binutils will expect to find the system headers and libraries under ${xprefix}/${xtarget_arch} so you will need to copy those files from the target system, preserving directory structure and modify any scripts as necessary. You should copy over the X11 lib and include dirs as well.

    Note: If your target system uses glibc, you must take special care to modify the local copy of the target's /usr/lib/ file (which is actually a script) so that it looks for its files under $xprefix/$target_arch rather than /usr.

    If you already have rpms for the target system and rpm installed on the build system, then you can use this shortcut script which should install the rpms into $xprefix/$xtarget_arch using rpm2cpio.

    Also, if you use Debian or Ubuntu, you can use dpkg-cross or apt-cross to install the headers and libraries for target system.

    Cross-compile gcc

    Download gcc and run configure with the following command:

    ./configure --prefix=${xprefix} --with-gnu-ld --with-gnu-as --target=${xtarget_arch} --disable-nls --enable-languages=c++,objc

    Build and install the package on the system.


    At this point, your cross-compilation environment should be completely set up. You should verify that it works. Start with Hello World and work your way up to a basic X11-based application.

    For most packages, ./configure --target=${xtarget_arch} should be sufficient to build.

    For others, you may have to explicitly set the build tools:

    env AR=${xtarget_arch}-ar CC=${xtarget_arch}-gcc CXX=${xtarget_arch}-g++ LD=${xtarget_arch}-ld AS=${xtarget_arch}-as ./configure --prefix=${xprefix} --target=${xtarget_arch}

    Cross-compile glib, libIDL & gtk+

    This step is only necessary if you did not install pre-built versions of these packages. Use the steps outlined above to build and install them.

    Cross-compiling the lizard

    Assuming that you properly setup your cross-compilation build environment as outlined above, cross-compiling Mozilla is fairly straightforward although NSS isn't properly setup to cross-compile (bug 104541).

    The main thing to remember is that when --target=${xtarget_arch} is passed to configure, configure expects to find the compiler toolchain as ${xtarget_arch}-TOOL where TOOL is gcc, g++, ranlib, etc.

    You must pass the following environment arguments to configure:

    HOST_LIBIDL_CONFIG='libIDL-config-2 --prefix=/path/to/build/system'
    HOST_LIBIDL_CFLAGS='-I/path/to/build/system/include/libIDL-2.0 -I/path/to/build/system/include/glib-2.0 -I/path/to/build/system/include'
    HOST_LIBIDL_LIBS='-L/path/to/build/system/lib -lIDL-2 -lglib-2.0'
    LIBIDL_CONFIG='libIDL-config-2 --prefix=/path/to/target/system'
    export PKG_CONFIG_PATH=/path/to/target/system/lib/pkgconfig

    and the follwing command line arguments to configure:


    Here's a sample mozconfig file used to cross-compile to the mipsEEel-linux target:

    # sh
    # Build configuration script
    # See for build instructions.
    HOST_LIBIDL_CONFIG='/usr/bin/libIDL-config-2 --prefix=/usr'
    HOST_LIBIDL_CFLAGS='-I/usr/include/libIDL-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
    HOST_LIBIDL_LIBS='-L/usr/lib -lIDL-2 -lglib-2.0'
    LIBIDL_CONFIG='/usr/bin/libIDL-config-2 --prefix=/usr/mipsEEel-linux'
    export PKG_CONFIG_PATH=/usr/mipsEEel-linux/lib/pkgconfig
    # don't use pkg-config for host libIDL
    ac_add_options --without-libIDL
    ac_add_options --prefix=/usr/mipsEEel-linux
    ac_add_options --target=mipsEEel-linux
    # Options for 'configure' (same as command-line options). 
    # all are listed so that one can manually tweak this config file.
    ac_add_options --enable-application=browser
    ac_add_options --enable-mathml
    ac_add_options --enable-extensions
    #ac_add_options --enable-crypto
    ac_add_options --enable-logrefcnt
    ac_add_options --without-system-nspr
    ac_add_options --without-system-zlib
    ac_add_options --without-system-jpeg
    ac_add_options --without-system-png

    Original Document Information

    • Author(s): Chris Seawood
    • Last Updated Date: June 22, 2002
    • Copyright Information: Portions of this content are © 1998–2007 by individual contributors; content available under a Creative Commons license | Details.

    Document Tags and Contributors

    Contributors to this page: BenjaminSmedberg, mkato, kohei.yoshino, GavinSharp, Mgjbot
    Last updated by: GavinSharp,