3338 lines · 99.6 KB · HTML
RawDownload
<!DOCTYPE html><html lang="en"><head>     <meta http-equiv="content-type" content="text/html; charset=utf-8">     <title>MXE (M cross environment)</title>     <link rel="stylesheet" href="assets/common.css"> </head><body> <div id="navigation"><h1>MXE (M&nbsp;cross&nbsp;environment)</h1>     <ul>        <li><a href="#introduction"     >Introduction</a></li>        <li><a href="#screenshots"      >Screenshots</a></li>        <li><a href="#tutorial"         >Tutorial</a></li>        <li><a href="#download"         >Download</a></li>        <li><a href="https://lists.nongnu.org/mailman/listinfo/mingw-cross-env-list">Mailing List</a></li>        <li><a href="https://github.com/mxe/mxe/issues">Issue Tracker</a></li>        <li><a href="https://mxe.zulipchat.com/">Async Chat (Trial)</a></li>    </ul>    <ul>        <li><a href="#requirements"     >Requirements</a></li>        <li><a href="#usage"            >Usage</a></li>        <li><a href="#packages"         >List of Packages</a></li>        <li><a href="#creating-packages">Creating Packages</a></li>        <li><a href="#copyright"        >Copyright</a></li>        <li><a href="#legal"            >Legal</a></li>        <li><a href="#history"          >History</a></li>    </ul>    <ul>        <li><a href="#see-also"         >See also</a></li>        <li><a href="#used-by"          >Used by</a></li>    </ul></div> <div class="section"><h2 id="introduction">Introduction</h2>     <p>    MXE (M cross environment) is a GNU Makefile that    compiles a cross compiler and cross compiles    many free libraries such as SDL and Qt. Thus,    it provides a nice cross compiling environment    for various target platforms, which    </p>     <ul>    <li>        is designed to        <a href="#requirements">run on any Unix system</a>    </li>    <li>        is easy to adapt and to extend    </li>    <li>        builds        <a href="#packages">many free libraries</a>        in addition to the cross compiler    </li>    <li>        can also        <a href="#usage">build just a subset</a>        of the packages,        and automatically builds their dependencies    </li>    <li>        downloads all needed packages        and verifies them by their checksums    </li>    <li>        is able to update the version numbers of all packages automatically    </li>    <li>        directly uses source packages,        thus ensuring the whole build mechanism is transparent    </li>    <li>        allows inter-package and intra-package        <a href="#usage">parallel builds</a>        whenever possible    </li>    <li>        bundles <a href="https://ccache.samba.org">ccache</a> to speed        up repeated builds    </li>    <li>        integrates well with <a href="#tutorial-5a">autotools</a>,        <a href="#tutorial-5b">cmake</a>, <a href="#tutorial-5c">qmake</a>,        and <a href="#tutorial-5d">hand-written makefiles</a>    </li>    <li>        has been in continuous development <a href="#history">since 2007</a>        and is <a href="#used-by">used by several projects</a>    </li>    <li>        has <a href="https://pkg.mxe.cc/">pre-compiled binaries</a>        that <a href="https://github.com/zer0main/battleship">can be used        in Continuous Integration systems</a>    </li>    </ul>     <h3>Supported Toolchains</h3>     <p>        Compiler and runtime: MinGW-w64.    </p>     <table id="supported-toolchains">    <tr>        <th rowspan="2">Target OS</th>        <th colspan="2">Packages</th>    </tr>    <tr>        <th>Static</th>        <th>Shared</th>    </tr>    <tr>        <td>32 bit Windows</td>        <td style='text-align:center'>99% (379/381)</td>        <td style='text-align:center'>72% (273/381)</td>    </tr>    <tr>        <td>64 bit Windows</td>        <td style='text-align:center'>94% (360/381)</td>        <td style='text-align:center'>71% (271/381)</td>    </tr>    </table>    <p>        These numbers were last updated on December 16, 2015.        See the <a href="build-matrix.html">current status</a>        for individual packages.    </p>    <p>        Executables built for 32 bit Windows can be        executed on 64 bit Windows as well.    </p>    <p>        How to choose MXE target:    </p>        <ol>            <li>If you want a 64 bit Windows executable,                statically linked into one big executable:                use MXE_TARGETS x86_64-w64-mingw32.static;</li>            <li>If you want a 64 bit Windows executable,                split into an executable and dependant dlls                use MXE_TARGETS x86_64-w64-mingw32.shared;</li>            <li>If you want a 32 bit Windows executable,                statically linked into one big executable:                use MXE_TARGETS i686-w64-mingw32.static;</li>            <li>If you want a 32 bit Windows executable,                split into an executable and dependant dlls                use MXE_TARGETS i686-w64-mingw32.shared.</li>        </ol>    <p>        Remark: The 'w64-mingw32' in those names are left-overs from        historical evolutions in the open source cross-compilation world        and refer in no way to the result being 64 or 32 bit Windows.    </p>    <p>        OpenMP (<a href="https://gcc.gnu.org/projects/gomp/">libgomp</a>)        and pthreads (<a href="https://mingw-w64.sourceforge.io/">winpthreads</a>)        are always available.    </p>    <p>        When building shared libraries, there are several approaches to        recursively finding DLL dependencies (alphabetical list):    </p>        <ul>        <li>            <a href="https://github.com/desertbit/gml/blob/master/cmd/gml-copy-dlls/main.go">            go script</a>        </li>        <li>            <a href="https://github.com/gsauthof/pe-util">pe-util</a>            packaged with            <a href="https://github.com/mxe/mxe/blob/master/src/pe-util.mk">mxe</a>        </li>        <li>            <a href="https://github.com/mxe/mxe/blob/master/tools/copydlldeps.py">python script</a>        </li>        <li>            <a href="https://github.com/mxe/mxe/blob/master/tools/copydlldeps.md">shell script</a>        </li>        </ul>    <p>        Experimental support for GCC with posix threads was        added in <a href="https://github.com/mxe/mxe/pull/958">November 2015</a>. Since <a href="https://github.com/mxe/mxe/pull/2263">January 2019</a> it is used by default.    </p>    <p>        Experimental support for alternate GCC Exception Handling was        added in <a href="https://github.com/mxe/mxe/pull/1664">February 2017</a>.    </p> </div> <div class="section"><h2 id="screenshots">Screenshots</h2>     <p>    Cross compiling    <a href="https://thebeez.home.xs4all.nl/4tH/">4tH</a>:    </p>    <a href="assets/screenshot-4th-compile.png">        <img src="assets/screenshot-4th-compile-small.png" alt="4th-compile">    </a>     <p>    and running it:    </p>    <a href="assets/screenshot-4th-run.png">        <img src="assets/screenshot-4th-run-small.png" alt="4th-run">    </a></div> <div class="section"><h2 id="tutorial">Tutorial</h2>     <h3 id="tutorial-1">Step 1: Requirements and Download</h3>     <p>    First, you should ensure that your system meets    MXE's    <a href="#requirements">requirements</a>.    You will almost certainly have to install some stuff.    </p>     <p>    When everything is fine, download the    <a href="#download">current version</a>:    </p>    <pre>git clone https://github.com/mxe/mxe.git</pre>     <p>    If you don't mind installing it in your home directory,    just skip the following step and go straight to step 3.    </p>     <p>    MXE builds and installs everything under the same    top-level directory and is not relocatable after    the first packages are built.    </p>     <p>    Due to limitations of GNU Make, the path of MXE is not allowed    to contain any whitespace characters.    </p>     <h3 id="tutorial-2">Step 2: System-wide Installation (optional)</h3>     <p>    Now you should save any previous installation    of the MXE.    Assuming you've installed it under    /opt/mxe (any other directory will do as well),    you should execute the following commands:    </p>    <pre>sumv /opt/mxe /opt/mxe.oldexit</pre>     <p>    Then you need to transfer the entire directory to its definitive location.    We will assume again you use /opt/mxe,    but feel free to use any other directory if you like.    </p>    <pre>sumv mxe /opt/mxeexit</pre>     <p>    We're almost done.    Just change to your newly created directory and get going:    </p>    <pre>cd /opt/mxe</pre>     <h3 id="tutorial-3">Step 3a: Build MXE</h3>     <p>    Enter the directory where you've downloaded MXE.    Now it depends on what you actually want &ndash; or need.    </p>     <p>    If you choose to enter:    </p>    <pre>make</pre>    <p>    you're in for a long wait,    because it compiles    <a href="#packages">a lot of packages</a>.    On the other hand it doesn't require any intervention,    so you're free to do whatever you like    &ndash; like watch a movie or go for a night on the town.    When it's done you'll find that you've installed    a very capable Win32 cross compiler onto your system.    </p>     <p>    If you only need the most basic tools you can also use:    </p>    <pre>make cc</pre>    <p>    and add any additional packages you need later on.    You can also supply a host of packages on the    <a href="#usage">command line</a>,    e.g.:    </p>    <pre>make gtk lua libidn</pre>    <p>    Targets can also be specified on the command line.    By default, only i686-w64-mingw32.static is built, but you can    build your toolchain(s) of choice with:    </p>    <pre>make MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static'</pre>    <p>    or by adjusting the <code>MXE_TARGETS</code> variable    in <code>settings.mk</code>.    </p>    <p>    You'll always end up with a consistent cross compiling environment.    </p>     <p>    If you have trouble here, please feel free to    contact the mxe team through the    <a href="https://github.com/mxe/mxe/issues">issue tracker</a> or    <a href="https://lists.nongnu.org/mailman/listinfo/mingw-cross-env-list">mailing list</a>.    </p>     <p>    After you're done it just needs a little post-installation.    </p>     <h3 id="tutorial-3b">Step 3b: Install MXE from the binary distribution</h3>     <p>    Instead of building MXE packages from source, you can install    packages from our APT repository for the following distros:    </p>    <ul>    <li>Debian (stable and old stable)</li>    <li>Ubuntu LTS (at least two releases supported)</li>    </ul>    <p>    See the    <a href="https://pkg.mxe.cc/repos/apt/dists/">distro list</a>    for current codenames and last build dates.    </p>    <p>    Ensure required tools are available (usually installed by default):    </p>    <pre>sudo apt-get install \    software-properties-common \    lsb-release</pre>    <p>    Add and refresh MXE repository:    </p>    <pre>sudo apt-key adv \    --keyserver keyserver.ubuntu.com \    --recv-keys 86B72ED9 && \sudo add-apt-repository \    "deb [arch=amd64] https://pkg.mxe.cc/repos/apt `lsb_release -sc` main" && \sudo apt-get update</pre>    <p>    Note that all package and target names have underscores replaced with    dashes. For example:    </p>    <pre>apt-cache search 'mxe.*sdl_net'</pre>    <p>    outputs:    </p>    <pre>mxe-i686-w64-mingw32.shared-sdl-net - MXE package sdl_net for i686-w64-mingw32.sharedmxe-i686-w64-mingw32.static-sdl-net - MXE package sdl_net for i686-w64-mingw32.staticmxe-x86-64-w64-mingw32.shared-sdl-net - MXE package sdl_net for x86_64-w64-mingw32.sharedmxe-x86-64-w64-mingw32.static-sdl-net - MXE package sdl_net for x86_64-w64-mingw32.static</pre>    <p>    Install the basic cross-compiler:    </p>    <pre>sudo apt-get install \    mxe-{i686,x86-64}-w64-mingw32.{static,shared}-cc</pre>    <p>    Confirm installation (note standard MXE target naming for tools):    </p>    <pre>PATH=/usr/lib/mxe/usr/bin:$PATH \    x86_64-w64-mingw32.static-gcc --version</pre>    <p>    outputs:    </p>    <pre>x86_64-w64-mingw32.static-gcc (GCC) 5.5.0Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</pre>    <p>    See the Lightspark project for examples of:    </p>    <ul>    <li><a href="https://github.com/lightspark/lightspark/blob/86275b12218b7aeaabdeece6d8f8d0c17e2ba843/.travis.yml#L34">    integration with CI system</a></li>    <li><a href="https://github.com/lightspark/lightspark/blob/86275b12218b7aeaabdeece6d8f8d0c17e2ba843/.travis.yml#L61">    adding modified source build to pre-built installation</a></li>    </ul>     <h3 id="tutorial-4">Step 4: Environment Variables</h3>     <p>    Edit the appropriate config script (.bashrc, .cshrc, .profile, .zshrc, etc.)    for your shell in order to change $PATH:    </p>    <pre>export PATH=/<em>where MXE is installed</em>/usr/bin:$PATH</pre>     <p>    You may be tempted to also add <code>$(TARGET)/bin</code>    to your path. You <strong>never</strong> want to do this,    the executables and scripts in there will cause conflicts    with your native toolchain.    </p>     <p>    In case you are using custom $PKG_CONFIG_PATH entries,    you can add separate entries for cross builds:    </p>    <pre>export PKG_CONFIG_PATH="<em>entries for native builds</em>"</pre>    <pre>export PKG_CONFIG_PATH_i686_w64_mingw32_static="<em>entries for MXE builds</em>"</pre>    <p>    Remember to use i686-w64-mingw32.static-pkg-config    instead of pkg-config for cross builds.    The Autotools do that automatically for you.    </p>     <p>    Note that any other compiler related environment variables    (like $CC, $LDFLAGS, etc.)    may spoil your compiling pleasure,    so be sure to delete or disable those.    </p>    <p>    For the most isolated and repeatable environment,    use a white-list approach:    </p>    <pre>unset `env | \    grep -vi '^EDITOR=\|^HOME=\|^LANG=\|MXE\|^PATH=' | \    grep -vi 'PKG_CONFIG\|PROXY\|^PS1=\|^TERM=' | \    cut -d '=' -f1 | tr '\n' ' '`</pre>    <!-- update mxe-activate also -->    <p>    Congratulations!    You're ready to cross compile anything you like.    </p>     <h3 id="tutorial-5a">Step 5a: Cross compile your Project (Autotools)</h3>     <p>    If you use the    <a href="https://www.lrde.epita.fr/~adl/autotools.html">Autotools</a>,    all you have to do is:    </p>    <pre>./configure --host=i686-w64-mingw32.staticmake</pre>     <p>    If you build a library, you might also want to enforce a static build:    </p>    <pre>./configure --host=i686-w64-mingw32.static --enable-static --disable-sharedmake</pre>     <p>    Don't worry about a warning like this:    </p>    <pre>configure: WARNING: If you wanted to set the --build type, don't use --host.If a cross compiler is detected then cross compile mode will be used.</pre>    <p>    Everything will be just fine.    </p>     <h3 id="tutorial-5b">Step 5b: Cross compile your Project (CMake)</h3>     <p>    If you have a    <a href="https://www.cmake.org/">CMake</a> project,    you can use the provided cmake wrapper:    </p>    <pre>i686-w64-mingw32.static-cmake ...</pre>    <p>    This will automatically use the MXE version of cmake    and locate the toolchain file.    </p>     <h3 id="tutorial-5c">Step 5c: Cross compile your Project (Qt)</h3>     <p>    If you have a    <a href="https://qt-project.org/">Qt</a> application,    all you have to do is:    </p>

Lines 1–500 of 3338.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t