1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
# Cross-compile from Linux to Windows
## Intro
Following these instructions you will be able to cross-compile qTox for
Windows.
This script can be used by qTox users and devs to compile qTox for Windows
themselves.
Please note that the compilation script doesn't build the updater.
## Usage
[Install Docker](https://docs.docker.com/install).
Create 2 directories:
* `workspace` -- a directory that will contain a cache of qTox dependencies
and the final qTox cross-compilation build. You should create this directory.
* `qtox` -- the root directory of a qTox repository. This directory must
contain the qTox source code that will be cross-compiled.
These directories will be mounted inside a Docker container at `/workspace` and
`/qtox`.
> Note:
> The contents of `qtox` directory are not modified during compilation. The
> `build.sh` script makes a temporary copy of the `qtox` directory for the
> compilation.
Once you sort out the directories, you are ready to run the `build.sh` script
in a Docker container.
> Note:
> The`build.sh` script takes 2 arguments: architecture and build type.
> Valid values for the architecture are `i686` for 32-bit and `x86_64` for
> 64-bit. Valid values for the build type are `release` and `debug`. All
> case sensitive.
To start cross-compiling for 32-bit release version of qTox run:
```sh
sudo docker run --rm \
-v /absolute/path/to/your/workspace:/workspace \
-v /absolute/path/to/your/qtox:/qtox \
debian:stretch-slim \
/bin/bash /qtox/windows/cross-compile/build.sh i686 release
```
If you want to debug some compilation issue, you might want to instead run:
```sh
# Get shell inside Debian Stretch container so that you can poke around if needed
sudo docker run -it \
--rm \
-v /absolute/path/to/your/workspace:/workspace \
-v /absolute/path/to/your/qtox:/qtox \
debian:stretch-slim \
/bin/bash
# Run the script
bash /qtox/windows/cross-compile/build.sh i686 release
```
These will cross-compile all of the qTox dependencies and qTox itself, storing
them in the `workspace` directory. The first time you run it for each
architecture, it will take a long time for the cross-compilation to finish, as
qTox has a lot of dependencies that need to be cross-compiled. But once you do
it once for each architecture, the dependencies will get cached inside the
`workspace` directory, and the next time you build qTox, the `build.sh` script
will skip recompiling them, going straight to compiling qTox, which is a lot
faster.
> Note:
> On a certain Intel Core i7 processor, a fresh build takes about 125
> minutes on a single core, and about 30 minutes using all 8 hyperthreads.
> Once built, however, it takes about 8 minutes on a single core and 2
> minutes using 8 hyperthreads to rebuild using the cached dependencies.
After cross-compiling has finished, you should find the comiled qTox in a
`workspace/i686/qtox` or `workspace/x86_64/qtox` directory, depending on the
architecture.
You will also find `workspace/dep-cache` directory, where all the
cross-compiled qTox dependencies will be cached for the future builds. You can
remove any directory inside the `dep-cache`, which will result in the
`build.sh` re-compiling the removed dependency only.
The `workspace` direcory structure for reference:
```
workspace
├── i686
│ ├── dep-cache
│ │ ├── libexif
│ │ ├── libffmpeg
│ │ ├── libfilteraudio
│ │ ├── libopenal
│ │ ├── libopenssl
│ │ ├── libopus
│ │ ├── libqrencode
│ │ ├── libqt5
│ │ ├── libsodium
│ │ ├── libsqlcipher
│ │ ├── libtoxcore
│ │ ├── libvpx
│ │ ├── mingw-w64-debug-scripts
│ │ ├── nsis
│ │ └── nsis_shellexecuteasuser
│ └── qtox
│ ├── debug
│ └── release
└── x86_64
├── dep-cache
│ ├── libexif
│ ├── libffmpeg
│ ├── libfilteraudio
│ ├── libopenal
│ ├── libopenssl
│ ├── libopus
│ ├── libqrencode
│ ├── libqt5
│ ├── libsodium
│ ├── libsqlcipher
│ ├── libtoxcore
│ ├── libvpx
│ ├── mingw-w64-debug-scripts
│ ├── nsis
│ └── nsis_shellexecuteasuser
└── qtox
├── debug
└── release
```
|