-
-
Notifications
You must be signed in to change notification settings - Fork 101
kiwix desktop windows.
This is attempt to build kiwix-desktop on Windows. It seems it is pretty complex and, no suspense, I have NOT succeed for now.
However, documenting thing is still good anyway.
DISCLAIMER : This documentation is full of nasty, crappy things, it is ugly and it will give you nightmare. I'm NOT responsible the damages it may inflict you.
I strongly advice to carefully follow this instruction. Every steps and options are important :) However, this documentation is not complete, it is mainly inspired from the notes I've taken. You will have to fill the gaps.
Some general advises:
- Do not install something else than specified
- Remove chocolatey packages, cygwin, mingw, python, ...
- Do not use space in your path. If your user is "FirstName FamillyName", change it !
- You will need a Windows computer and a Linux one.
- This have been tested with windows 10. It may work with something else or not.
The dependencies of kiwix-desktop are the following :
kiwix-desktop (C++)
+- QT (C++)
+- QTWebEngine (C++)
+- kiwix-lib (C++)
+- pugixml (C++)
+- zlib (C)
+- lzma (C)
+- icu4c (C/C++)
+- libzim (C++)
+- zlib (C)
+- lzma (C)
+- icu4c (C/C++)
+- xapian (C++)
+- zlib (C)
As C++ has no standard ABI defined, we need to compile all C++ code with the same compiler. QTWebEngine is compilable only with MSVC on Windows and 64bits only. So, we need to compile all our C++ code with MSVC. Now, the nightmare can start.
- QT/QTWebengine. A prebuild version exist, compiled with VC 2017
- pugixml. Pretty easy to compile.
- zlib. A prebuild version exist but 32 bits...
- lzma. Yeah, prebuild version 64 bits. It is compiled with mingw64, but as it is C, no problem.
- icu4c. Microsoft provide a version in Windows, but only the C API (especially because C++ has no standard ABI). However, we are using the C++ API and porting to the C API will be ... difficult. ICU project provide a prebuild lib using VC. ICU also provide a MSVC project to allow recompilation.
- xapian ... Is build using autotools... Autotools is a nightmare on linux... but it works. On Windows ... [sic]. However xapian folks have start to work on allowing compilation of xapian using MSVC. It is not released yet, but we will use it anyway. (Guys, you are crazy, you've wrote a wrapper around MSVC to transform options in gcc style to MSVC style. Because autotool is crappy). Anyway, all those tools are GNU tools so, we need a Posix env in Windows. We will use Msys2 as xapian doc recommend it.
Our project use meson to compile. meson handles MSVC compiler, so nothing special on this (except few bugs)
As xapian is not yet release, we will need to run maintainer tools, that are available only on Linux, so, keep a linux around. And you will have to copy files from linux to windows, you'd better setup a ssh connection between the two.
We will need it to clone repository. Dl https://github.com/git-for-windows/git/releases/download/v2.18.0.windows.1/Git-2.18.0-32-bit.exe and install git in C:\git.
Hopefully, there is a meson installer that embedded python and ninja, lets use it:
Dl https://github.com/mesonbuild/meson/releases/download/0.46.1/meson-0.46.1-64.msi and install meson in C:\meson
We will need pkg-config to allow meson to find dependencies. pkg-config needs glib. Hopelly, there is a lite version without glib dependencie: DL https://sourceforge.net/projects/pkgconfiglite/files/0.28-1/ Extract the zim to C:\ (it will create the directory pkg-config-lite) Add C:\pkg-config-lite\bin to PATH (see annex)
...
VC will be installed, but the cl compilator will not be in the path by default. You will need to run C:\VC....\vcvars64.bat in cmd to have it.
Will will need something that look like a unix system on windows.
DL http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20180531.exe Follow the instruction there (https://www.msys2.org/) to have a up-to-date installation Install it in C:\msys64 (the default)
...
The pre-build binary provided by zlib project is a 32bits binary. So we need to compile zlib ourselves.
In a cmd window :
C:\VC\..\vcvars64.bat
get http://zlib.net/fossils/zlib-1.2.11.tar.gz
get https://wrapdb.mesonbuild.com/v1/projects/zlib/1.2.11/3/get_zip
Extract both in zlib directory.
cd zlib
meson . build --prefix C:/Users/<myuser>/dependencies --default-library static --buildtype release
cd build
ninja
ninja install
The pre-build version of libzim is multi arch, we can directly use it.
- Dl lzma archive (https://tukaani.org/xz/xz-5.2.4-windows.zip)
- Extract it in C:/User/<myuser>/dependencies
- Add a pkgconfig file (because meson need it)
Surprise !
A lot of project use pthread to handle threads. However windows doesn't provide pthread. We can get a implementation here :
- ftp://sourceware.org/pub/pthreads-win32/dll-latest/lib/x64/pthreadVC2.lib
- ftp://sourceware.org/pub/pthreads-win32/dll-latest/dll/x64/pthreadVC2.dll
- ftp://sourceware.org/pub/pthreads-win32/dll-latest/include/pthread.h
- ftp://sourceware.org/pub/pthreads-win32/dll-latest/include/sched.h
Copy them in the right place in C:/User/<myuser>/dependencies.
Double surprise !
This is the same for dirent. A implementation, header only can be found here. https://github.com/tronkko/dirent Just copy the dirent.h in C:/User/<myuser>/dependencies/include
That's the tricky part. Xapian folks have started to make xapian support MSVC compilation. It should be available in the next release but for now we have to use the master branch of the git repository.
Le's go : First : Cry, then run cmd
C:\VC\...\vcvars64.bat
# We want to keep the path to cl in msys shell
set MSYS2_PATH_TYPE=inherit
# We don't want to have msys messup our path of option `-Tp` (but it is ok for other options...)
set MSYS2_ARG_CONN_EXCL=-Tp
# Let's run our mingw64 shell
C:\msys2\mingw64.exe
A new window opens, let's use it:
#install things
pacman -S make autotools
git clone https://github.com/xapian/xapian
cd xapian
./bootstrap
# Yes, it will compile a patched version of autotool, autoconf, libtool, ...
cd ..
export XAPIAN_SOURCE=$(pwd)/xapian/xapian-core
mkdir xapian-build
cd xapian-build
$XAPIAN_SOURCE/configure \
CC="cl -nologo" \
CXX="$XAPIAN_SOURCE/compile cl -nologo" \
CXXFLAGS="-EHsc -MD" AR=lib \
CPPFLAGS="-I/c/User/<myuser>/dependencies/include" \
LDFLAGS="-L/c/User/<myuser>/dependencies/lib" \
--disable-backend-remote \
--prefix=/c/Users/<myuser>/dependencies
Mention the -MD
options, because it is not added by default by xapian buildsystem. As meson will add it,
we need it here else MSVC will complains at final link.
Do almost the same things on linux, but use ./configure --enable-maintainer-mode --disable-documentation
make
xapian on linux.
On the msys2 window on Windows :
make
It will complain about missing (source) files, find them in xapian directory on linux and copy them on Windows. Then it will complain about missing man source (*.1). Simply find then in the makefile and remove them (Makefile and doc/Makefile).
Finally
make
make install
Scream of joy, you have succeed to compile xapian !
dl archive http://download.icu-project.org/files/icu4c/62.1/icu4c-62_1-Win64-MSVC2017.zip extract create icu18n.pc
Yes, libzim with meson will fail because of winnt.h. I don't know why but you can remove the instruction at line 11895 (and around) in C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\winnt.h
In cmd window:
VC\...\vcvars64.bat
git clone https://github.com/openzim/libzim
cd libzim
git checkout windows (when branch exists else patch)
meson . build --prefix C:/Users/<myuser>/dependencies --default-library static --buildtype release
cd build
ninja
ninja install
In cmd window:
VC\...\vcvars64.bat
git clone https://github.com/kiwix/kiwix-lib
cd kiwix-lib
git checkout windows (when branch exists else patch)
meson . build --prefix C:/Users/<myuser>/dependencies --default-library static --buildtype release
cd build
ninja
ninja install
In cmd window:
VC\...\vcvars64.bat
git clone https://github.com/kiwix/kiwix-desktop
cd kiwix-desktop
git checkout windows (when branch exists else patch)
C:\Qt\5.1.10\...\qmake
Fix makefile
Install make (triple suprise)
make
Fix makefile again
make
FIX MAKEFILE !!!
make
Try to run kiwix-desktop. Fails because of error 0xc000007b
- Right Click bottom left menu
- Parameter
- Information system
- Associated Parameter
- System information [new window]
- Advanced system parameter [new window]
- Env var
You can use http://www.dependencywalker.com/