Cross-Compile qBittorrent for Windows on Linux using MXE


It’s actually pretty easy to cross-compile qBittorrent on Linux for Windows targets using MXE, a cross environment based on the MinGW-w64 toolchain.

The MinGW-w64 project is an improvement on the original MinGW (Minimalist GNU for Windows) project to support 64-bits targets. Currently MXE supports two MinGW-w64 targets: i686-w64-mingw32 for 32-bits executables and x86_64-w64-mingw32 for 64-bits executables.

This is a guide to cross-compile qBittorrent on Linux for Windows 64-bits only.  As usual we’ll use Debian for this.

Configuring MXE

MXE is a cross environment that helps you cross-compile several Open Source libraries like Qt, OpenSSL, zlib, etc. This will make your life way easier if you want to cross-compile any of those projects.  Since qBittorrent uses Qt, boost, OpenSSL and zlib, we are going to tell MXE to cross-compile all those projects for us.

First things first, we need to download MXE and install the dependencies.  To get the most recent version we use git for this:

MXE needs several dependencies and depending on what you want to cross-compile you might need some of them, but not all.  MXE will tell you what you haven’t installed yet in order to cross-compile a project.  Anyway for a list of all dependencies you can go here.

We should first compile the cross-compiler itself, but it’s going to be installed anyway if I just tell MXE to cross-compile Qt, because it needs it.

We need to specify the target we want in an environment variable called MXE_TARGET. This target is x86_64-w64-mingw32.static.

So let’s try to cross-compile Qt 5 (we just need qtbase) to see what happens:

Looks like there’s some dependencies I haven’t installed yet. Since this is Debian I just need to issue:

And now everything is ready to cross-compile Qt 5 (qtbase only):

That takes a while as you might guess. Just leave it. But take a look again at the last 3 lines: the gcc compiler is being built as well and actually all the MinGW-w64 x86_64-w64-mingw32.static toolchain is going to be downloaded, compiled, and installed. Good!

Also OpenSSL and zlib where downloaded, cross-compiled, and installed it as well. So all is left is boost and libtorrent. Let’s go with boost:

I will configure libtorrent manually in the next step. That’s because I always want to try qBittorrent with several libtorrent versions, and if I use MXE to build libtorrent I will be stuck with 1.0.6. But if you don’t care about it just type:

And skip the next section.

Finally add the MXE path to your path:

Cross-Compile libtorrent-rasterbar

To cross-compile libtorrent you need to make a couple of minor changes.  Basically the problem is that Windows filesystem is case-insensitive, but Linux is case-sensitive. So things like:

will fail miserably in Linux.  You will need to edit all the include files that have capital letters and maybe change things like this:

to this

Since I was using libtorrent 1.0.6 I also had to change a bug in the code in file.cpp


And we’re ready. We just need to specify the target in the configure command and the location of the cross-compiled boost libraries:

And after the configuration just compile it and install it under the MXE libraries directory:


Cross-Compile qBittorrent

I had some problems with the configure program while trying to cross-compile qBittorrent. This is what happens:

And the configure program couldn’t complete because of that. The file is there I’m not sure why it doesn’t want to check if it’s there when cross compiling. So I couldn’t find another way but to change the configure file:

And also change the case of the #include entries that had capitalized letters on it.

After that you need to remove the BOOST_NO_CXXX11_RVALUE_REFERENCES definition in src/ to avoid this:

And finally configure the libraries folders and names in the pri files. Here’s the diff for src/

The diff for the winconf-mingw.pri file:

And the diff for the winconf.pri file:

And that’s it. We can configure qBittorrent and then run make and a 64-bits executable for Windows will be created in src/release/qbittorrent.exe.

2 thoughts to “Cross-Compile qBittorrent for Windows on Linux using MXE”

  1. configure: Running qmake to generate the makefile…
    Project MESSAGE: Building translations
    Project MESSAGE: Processing lang/qbittorrent_ar
    sh: 1: lrelease: not found
    Project ERROR: Building translations failed, cannot continue

    configure: error: Failed running /home/richard/mxe/usr/x86_64-w64-mingw32.static/qt5/bin/qmake to generate the makefile

    1. Since I have Qt installed natively in my Linux, I have /usr/bin/lrelease.

      If you don’t I guess you have to rebuild the toolchain with:

      make MXE_TARGETS=x86_64-w64-mingw32.static qttools

Leave a Reply