Skip to content

Commit 2a4ab6b

Browse files
authored
Merge pull request #6292 from elpaso/mxe
Scripts for cross build QGIS for windows on Linux with mxe
2 parents 9302613 + 4bd385f commit 2a4ab6b

File tree

10 files changed

+414
-21
lines changed

10 files changed

+414
-21
lines changed

INSTALL

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Last Change : Friday February 02, 2018
2323
4.1. Building with Microsoft Visual Studio
2424
4.2. Building using MinGW
2525
4.3. Creation of MSYS environment for compilation of QGIS
26+
4.4 Building on Linux with mxe
2627
5. Building on MacOS X
2728
5.1. Install Developer Tools
2829
5.2. Install Qt4 from disk image
@@ -1027,6 +1028,40 @@ We're done with preparation of MSYS environment. Now you can delete all stuff in
10271028
of space and it's not necessary at all.
10281029

10291030

1031+
1032+
4.4. Building on Linux with mxe
1033+
===============================
1034+
1035+
With this approach you can build a windows binary on Linux using mxe MXE (M cross environment).
1036+
You can find the build script and a README file in the ms-windows/mxe directory.
1037+
1038+
For now, Python buildings cannot be built with mxe.
1039+
1040+
4.4.1. Initial setup
1041+
====================
1042+
1043+
Please follow the instructions on mxe website to setup your building toolchain http://mxe.cc/,
1044+
take note of the path where you have installed mxe.
1045+
1046+
4.4.2. Building the dependencies
1047+
================================
1048+
1049+
Please see the README under ms-windows/mxe for a list of the dependencies that need to be
1050+
built in mxe before attempting to build QGIS.
1051+
1052+
1053+
4.4.3. Cross-Building QGIS
1054+
==========================
1055+
1056+
Edit the build-mxe.sh script and change the path where your mxe installation is located, you
1057+
can also change the build and release directory.
1058+
1059+
4.4.4. Testing QGIS
1060+
====================
1061+
1062+
Copy and unzip the release package on a Windows machine and launch it!
1063+
1064+
10301065
5. Building on MacOS X
10311066
======================
10321067

cmake/CreateQgsVersion.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ MACRO(CREATE_QGSVERSION)
22
IF (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
33
FIND_PROGRAM(GITCOMMAND git PATHS c:/cygwin/bin)
44
IF(GITCOMMAND)
5-
IF(WIN32)
5+
IF(WIN32 AND NOT CMAKE_CROSS_COMPILING)
66
IF(USING_NINJA)
77
SET(ARG %a)
88
ELSE(USING_NINJA)
@@ -16,7 +16,7 @@ MACRO(CREATE_QGSVERSION)
1616
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/.git/index
1717
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
1818
)
19-
ELSE(WIN32)
19+
ELSE(WIN32 AND NOT CMAKE_CROSS_COMPILING)
2020
ADD_CUSTOM_COMMAND(
2121
OUTPUT ${CMAKE_BINARY_DIR}/qgsversion.h ${CMAKE_BINARY_DIR}/qgsversion.inc
2222
COMMAND ${GITCOMMAND} log -n1 --pretty=\#define\\ QGSVERSION\\ \\"%h\\" >${CMAKE_BINARY_DIR}/qgsversion.h.temp
@@ -26,7 +26,7 @@ MACRO(CREATE_QGSVERSION)
2626
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/.git/index
2727
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
2828
)
29-
ENDIF(WIN32)
29+
ENDIF(WIN32 AND NOT CMAKE_CROSS_COMPILING)
3030
ELSE(GITCOMMAND)
3131
MESSAGE(STATUS "git marker, but no git found - version will be unknown")
3232
IF(NOT SHA)

ms-windows/mxe/README

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
2+
Scripts to cross build a windows QGIS binary from Linux using MXE:
3+
(M cross environment) http://mxe.cc/
4+
5+
For now, Python bindings cannot be built with mxe.
6+
7+
Follow the instructions on the website to prepare the mxe environment, you
8+
will need to build all required dependencies for QGIS.
9+
10+
Note that some of the packages listed below are dependencies of other
11+
packages, you will probably not need to build them all explicitly.
12+
13+
14+
armadillo
15+
bfd
16+
bzip2
17+
cairo
18+
cmake
19+
curl
20+
dbus
21+
dlfcn-win32
22+
expat
23+
fontconfig
24+
freetds
25+
freetype
26+
freexl
27+
gcc
28+
gdal
29+
gendef
30+
geos
31+
gettext
32+
giflib
33+
glib
34+
gmp
35+
gnutls
36+
gsl
37+
gta
38+
harfbuzz
39+
hdf4
40+
hdf5
41+
icu4c
42+
isl
43+
jasper
44+
jpeg
45+
json-c
46+
lcms
47+
libffi
48+
libgcrypt
49+
libgeotiff
50+
libgnurx
51+
libgpg_error
52+
libiconv
53+
libidn2
54+
libmng
55+
libmysqlclient
56+
libpng
57+
libspatialindex
58+
libssh2
59+
libunistring
60+
libwebp
61+
libxml2
62+
libzip
63+
lzo
64+
mpc
65+
mpfr
66+
netcdf
67+
nettle
68+
openblas
69+
openjpeg
70+
openssl
71+
pcre
72+
pcre2
73+
pixman
74+
pkgconf
75+
portablexdr
76+
postgresql
77+
proj
78+
qca
79+
qscintilla2
80+
qt3d
81+
qtactiveqt
82+
qtbase
83+
qtcanvas3d
84+
qtcharts
85+
qtconnectivity
86+
qtdatavis3d
87+
qtdeclarative
88+
qtgamepad
89+
qtgraphicaleffects
90+
qtimageformats
91+
qtkeychain
92+
qtlocation
93+
qtmultimedia
94+
qtpurchasing
95+
qtquickcontrols
96+
qtquickcontrols2
97+
qtscript
98+
qtscxml
99+
qtsensors
100+
qtserialbus
101+
qtserialport
102+
qtspeech
103+
qtsvg
104+
qttools
105+
qttranslations
106+
qtvirtualkeyboard
107+
qtwebchannel
108+
qtwebkit
109+
qtwebsockets
110+
qtwebview
111+
qtwinextras
112+
qtxmlpatterns
113+
qwt
114+
spatialite
115+
sqlite
116+
tiff
117+
xz
118+
zlib
119+
120+
When done, you can edit the build-mxe.sh script to set the path to your mxe installation.

ms-windows/mxe/build-mxe.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
###########################################################################
3+
# build-mxe.sh
4+
# ---------------------
5+
# Date : February 2018
6+
# Copyright : (C) 2018 by Alessandro Pasotti
7+
# Email : elpaso at itopen dot it
8+
###########################################################################
9+
# #
10+
# This program is free software; you can redistribute it and/or modify #
11+
# it under the terms of the GNU General Public License as published by #
12+
# the Free Software Foundation; either version 2 of the License, or #
13+
# (at your option) any later version. #
14+
# #
15+
###########################################################################
16+
17+
18+
set -e
19+
20+
# Usage: you can pass an optional "package" command to skip the build
21+
# and directly go to the packaging
22+
# This script needs to be called from the main QGIS directory, the
23+
# one which contains CMakeLists.txt
24+
25+
COMMAND=$1
26+
27+
# Location of current script
28+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
29+
PYDEPLOY=${DIR}/deploy.py
30+
31+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
32+
# Configuration: change this!
33+
34+
# Location of mxe install dir
35+
MXE=${HOME}/dev/mxe/
36+
37+
# Where the artifact will be saved
38+
39+
BUILD_DIR=`pwd`/build-mxe
40+
RELEASE_DIR=`pwd`/release-mxe
41+
42+
# End configuration
43+
44+
45+
46+
47+
if [[ "$COMMAND" != *"package"* ]]; then
48+
[ -d $BUILD_DIR ] && rm -rf $BUILD_DIR
49+
[ -d $RELEASE_DIR ] && rm -rf $RELEASE_DIR
50+
# Make sure dirs exist
51+
52+
[ -d $BUILD_DIR ] || mkdir $BUILD_DIR
53+
[ -d $RELEASE_DIR ] || mkdir $RELEASE_DIR
54+
[ -d $RELEASE_DIR/qt5 ] || mkdir $RELEASE_DIR/qt5
55+
56+
fi
57+
58+
pushd .
59+
60+
cd $BUILD_DIR
61+
62+
# Build
63+
64+
if [[ "$COMMAND" != *"package"* ]]; then
65+
66+
$MXE/usr/bin/i686-w64-mingw32.shared-cmake .. \
67+
-DCMAKE_BUILD_TYPE=Release \
68+
-DCMAKE_INSTALL_PREFIX=$RELEASE_DIR \
69+
-DENABLE_TESTS=OFF \
70+
-DWITH_QSPATIALITE=ON \
71+
-DWITH_APIDOC=OFF \
72+
-DWITH_QWTPOLAR=ON \
73+
-DWITH_ASTYLE=OFF \
74+
-DWITH_SERVER=OFF \
75+
-DWITH_BINDINGS=FALSE \
76+
-DQT_LRELEASE_EXECUTABLE=$MXE/usr/i686-w64-mingw32.shared/qt5/bin/lrelease \
77+
$ARGS
78+
79+
80+
make -j16 install
81+
82+
fi
83+
84+
# Collect deps
85+
86+
$PYDEPLOY --build=$RELEASE_DIR --objdump=$MXE/usr/bin/i686-w64-mingw32.shared-objdump ${RELEASE_DIR}/qgis.exe
87+
for dll in $(ls ${RELEASE_DIR}/*.dll); do \
88+
$PYDEPLOY --build=$RELEASE_DIR --objdump=$MXE/usr/bin/i686-w64-mingw32.shared-objdump $dll; \
89+
done
90+
91+
cp -r $MXE/usr/i686-w64-mingw32.shared/qt5/plugins $RELEASE_DIR/qt5
92+
93+
cat <<__TXT__ > ${RELEASE_DIR}/qt.conf
94+
[Paths]
95+
Plugins = qt5
96+
__TXT__
97+
98+
99+
popd
100+
101+
ZIP_NAME=release-`date +%Y-%m-%d-%H-%I-%S`.zip
102+
103+
zip -r $ZIP_NAME $RELEASE_DIR
104+
105+
echo "Release in $ZIP_NAME ready."

0 commit comments

Comments
 (0)