default to gb_Deliver_CLEARONDELIVER == as multiuserenv are rare now
[LibreOffice.git] / README.cross
blob7040685b6f49357c07eff488628156c4bc85ea8f
1 Cross-compiling LibreOffice
2 ===========================
4 Notes on cross-compiling LibreOffice, originally written by Tor
5 Lillqvist <tlillqvist@novell.com> <tml@iki.fi> in May, 2011, for later
6 history see git log.
8 My cross-compilation experimentation is going on for four platforms:
9 Windows, iOS, Android and PowerPC Mac OS X. I work on the master
10 branch of LibreOffice. Some other people have talked about setting up
11 a separate branch for Android work, or even separate clones at
12 github. I am not interested in that.
14 Cross-compilation of LibreOffice completely is not possible yet. Much
15 work has been done, "baby steps" for some platforms, much more for
16 others, but a lot remains. For iOS and Android this work is highly
17 experimental and done mostly in my own spare time just for the hacking
18 pleasure. No promise, explicit or implied, is given that it will ever
19 be finished.
21 Searching for information about cross-compilation of OpenOffice.org
22 (the predecessor of LibreOffice) you will find information about what
23 actually was not cross-compilation, but using QEMU.
26 General
27 -------
29 In GNU Autoconf terminology, "build" is the platform on which you are
30 running a build on some software and "host" is the platform on which
31 the software you are building will run. Only in the specific case of
32 building compilers and other programming tools is the term "target"
33 used to indicate the platform for which the tools your are building
34 will produce code. As LibreOffice is not a compiler, the "target" term
35 should not be used in the context of cross-compilation.
37 (For a case where all three of "build", "host" and "target" are
38 different: consider a gcc cross-compiler running on Windows, producing
39 code for Android, where the cross-compiler itself was built on
40 Linux. (This is a real case.) An interesting tidbit is that such
41 configurations are called "Canadian Cross".)
43 Even though the LibreOffice build mechanism is highly unorthodox, the
44 configure script takes the normal --build and --host options like any
45 GNU Autoconf -based configure script. To cross-compile, you basically
46 need just to specify a suitable --host option and things should work
47 out nicely. In practise, some more details might be needed. See
48 examples below.
51 What is so hard, then?
52 ----------------------
54 Despite the fact that the configure script takes normal --build and
55 --host options, that is just the beginning. In practise a lot of work
56 was necessary to separate tests for "host" and "build" platforms in
57 the configure script. See the git log for details. And the reasonably
58 "standard" configure.in is just the top level; when we get down to the
59 actual makefilery used to build the bits of LibreOffice, it gets much
60 worse.
63 Windows
64 -------
66 There is some support in LibreOffice already (from OpenOffice.org) for
67 building it locally on Windows with the GNU tool-chain (MinGW). But as
68 far as I know, that work has never attempted cross-compilation.
70 This OOo-originated MinGW support attempts to support both running
71 Cygwin gcc in its -mno-cygwin mode, and a native MinGW compiler. The
72 -mno-cygwin mechanism in the Cygwin gcc is rapidly being obsoleted, if
73 it isn't already, and I have not attempted to try to keep it working;
74 in fact I have activly cleaned out mechanisms related to this. Ditto
75 for native MinGW. If one compiles natively on Windows, just use
76 Microsoft's compiler. OOo/LO has been built for Windows all the time
77 using that.
79 In my opinion, the only case where it makes sense to use MinGW is for
80 cross-compilation. There is just too much crack on Windows anyway, and
81 it is a semi-miracle (well, make that the result of years of work)
82 that the MSVC build under Cygwin works as nicely as it does.
84 MinGW is available as cross-build toolchains pre-packaged in more or
85 less official packages for many Linux distros including Debian, Fedora
86 and openSUSE. Personally I use the mingw32 packages in the openSUSE
87 Build Service, running on openSUSE:
89 http://download.opensuse.org/repositories/windows:/mingw:/win32/
91 You can install it on openSUSE like this:
93 zypper ar http://download.opensuse.org/repositories/windows:/mingw:/win32/SLE_11_SP1/windows:mingw:win32.repo
94 zypper in mingw32-cross-gcc mingw32-cross-gcc-c++ mingw32-python-devel \
95     mingw32-libexpat-devel mingw32-libexpat mingw32-boost-devel \
96     mingw32-libhyphen-devel mingw32-libhyphen mingw32-hyphen-en \
97     mingw32-liblpsolve mingw32-liblpsolve-devel \
98     mingw32-libxml2-devel mingw32-libxslt-devel mingw32-libicu \
99     mingw32-libicu-devel mingw32-libgraphite2 mingw32-libgraphite2-devel \
100     mingw32-cairo mingw32-cairo-devel mingw32-librsvg mingw32-librsvg-devel \
101     mingw32-hunspell mingw32-hunspell-devel mingw32-libcurl \
102     mingw32-libcurl-devel mingw32-libneon mingw32-libneon-devel \
103     mingw32-libopenssl mingw32-libopenssl-devel mingw32-libtextcat \
104     mingw32-libtextcat-devel mingw32-libdb mingw32-libdb-devel \
105     mingw32-cross-pkg-config mingw32-pkg-config mingw32-libcppunit \
106     mingw32-libcppunit-devel mingw32-libredland mingw32-libredland-devel \
107     mingw32-libmythes mingw32-libmythes-devel
109 There might be more that are missing, please read carefully what autogen.sh
110 tells you, and either remove one of the --with-system-*, or install the
111 missing dependency.
113 It also looks like graphite2.pc needs tweaking in order to work right; but
114 that's likely to be fixed in the openSUSE project.
116 It is somewhat unclear how well thought-out the conditionals and code
117 for MinGW inside the OOo-originated code in LibreOffice actually
118 are. What I have noticed of it seems a bit randomish, with
119 copy-pasting having been preferred to factoring out differences.
121 The autogen.lastrun I use for my MinGW cross-compilation experimentation is:
123 CC=ccache i686-w64-mingw32-gcc
124 CXX=ccache i686-w64-mingw32-g++
125 CC_FOR_BUILD=ccache gcc
126 CXX_FOR_BUILD=ccache g++
127 --build=x86_64-unknown-linux-gnu
128 --host=i686-w64-mingw32
129 --with-distro=LibreOfficeWin32
130 --disable-activex
131 --disable-binfilter
132 --disable-build-mozilla
133 --disable-directx
134 --disable-ext-nlpsolver
135 --disable-ext-pdfimport
136 --disable-ext-presenter-console
137 --disable-ext-presenter-minimizer
138 --disable-ext-report-builder
139 --disable-ext-scripting-beanshell
140 --disable-ext-scripting-javascript
141 --disable-ext-wiki-publisher
142 --disable-ext-wiki-publisher
143 --disable-mozilla
144 --disable-zenity
145 --enable-python=system
146 --with-external-tar=/mnt/hemulen/ooo/git/master/src
147 --with-num-cpus=1
148 --with-max-jobs=1
149 --with-system-altlinuxhyph
150 --with-system-boost
151 --with-system-cairo
152 --with-system-cppunit
153 --with-system-curl
154 --with-system-db
155 --with-system-expat
156 --with-system-gettext
157 --with-system-hunspell
158 --with-system-icu
159 --with-system-libpng
160 --with-system-libwpd
161 --with-system-libwpg
162 --with-system-libwps
163 --with-system-libxml
164 --with-system-libxslt
165 --with-system-lpsolve
166 --with-system-mythes
167 --with-system-neon
168 --with-system-openssl
169 --with-system-redland
170 --with-vendor=no
171 --without-help
172 --without-helppack-integration
173 --without-myspell-dicts
175 For reference, Kendy's autogen.lastrun is:
177 CC=ccache i686-w64-mingw32-gcc
178 CXX=ccache i686-w64-mingw32-g++
179 CC_FOR_BUILD=ccache gcc
180 CXX_FOR_BUILD=ccache g++
181 --build=x86_64-unknown-linux-gnu
182 --host=i686-w64-mingw32
183 --with-num-cpus=4
184 --with-max-jobs=8
185 --without-junit
186 --disable-binfilter
187 --disable-build-mozilla
188 --disable-mozilla
189 --with-system-altlinuxhyph
190 --with-system-boost
191 --with-system-cairo
192 --with-system-cppunit
193 --with-system-curl
194 --with-system-db
195 --with-system-expat
196 --with-system-gettext
197 --with-system-graphite
198 --with-system-hunspell
199 --with-system-icu
200 --with-system-libpng
201 --with-system-libxml
202 --with-system-libxslt
203 --with-system-lpsolve
204 --with-system-mythes
205 --with-system-neon
206 --with-system-openssl
207 --with-system-redland
208 --without-myspell-dicts
209 --disable-directx
210 --disable-activex
211 --disable-extension-integration
213 Once you have compiled it, you may want to try to run it:
215 $ cd /tmp
216 $ tar xf <your-build-dir>/instsetoo_native/wntgcci.pro/LibreOffice_Dev/archive/install/en-US/LibO-Dev_OOO350m1_Win_x86_install-arc_en-US.tar.gz
217 $ cd LibO-Dev_OOO350m1_Win_x86_install-arc_en-US/LibO-dev\ 3.5/program
218 $ wine soffice.exe
220 NB. it is important to unpack somewhere low in the hierarchy structure (like
221 in /tmp as advised above), otherwise you'll get BerkeleyDB errors on startup.
223 And if you are brave enough, you can even debug it.  First you have to add the
224 URE dll's to the wine's PATH using 'wine regedit' - see
225 http://www.winehq.org/docs/wineusr-guide/environment-variables, and add
226 Z:\tmp\LibO-Dev_OOO350m1_Win_x86_install-arc_en-US\LibO-dev 3.5\URE\bin
227 to "Path" in My Computer->HKEY_CURRENT_USER->Environment.
229 Then run linkoo, so that when you rebuild something, you can directly see the
230 changes the next time you run it:
232 solenv/bin/linkoo '/tmp/LibO-Dev_OOO350m1_Win_x86_install-arc_en-US/LibO-dev 3.5' <your_clone_dir>
234 And start debugging:
236 $ winedbg soffice.bin
238 Would be great to be able to use winedbg --gdb, but it was crashing here :-( -
239 but maybe you'll be more lucky.
241 TODO:
243 - installation
244   - so far the make_installer.pl calls makecab.exe, uuidgen.exe, and
245     others; would be best to avoid that if at all possible (using a free
246     cab implementation, part of Wine or something)
247   - MSI generation
248   - if at all possible, the make dev-install installation (with links
249     back to the build) should be done so that it would be directly
250     executable via wine after doing make dev-install :-)
252 - runtime
253   - no idea if the entire thing works after the installation at all; I
254     suppose there will be runtime problems to look at too
256 - cleanup
257   - enable & fix pieces that are currently disabled
258     - --without-myspell-dicts
259     - --disable-directx
260     - --disable-activex
261     - --disable-mozilla
262   - much of the stuff currently relies on --with-system-*, and
263     consequently on the mingw32-* openSUSE packages; might be good to be
264     able to build with as few dependencies as possible - but that is low
265     prio I think
267 - profiling
268   - when all the above is sorted out, we should look at the speed of
269     this vs. the speed of the MSVC version
275 iOS is the operating system of Apple's mobile devices. Clearly for a
276 device like the iPad it would be totally unacceptable to run a normal
277 LibreOffice application with a overlapping windows and mouse-oriented
278 GUI widgets. No work has been done (at least publicly) to design a
279 touch GUI for LibreOffice, so the work on cross-compiling LibreOffice
280 for iOS is extremely experimental, and of course partly pointless;)
281 But it is interesting and fun nonetheless.
283 Obviously it will make sense to build only a part of LibreOffice's
284 code for iOS. Most likely all GUI-oriented code should be left out,
285 and some iOS app that eventually wants to use the remaining bits will
286 handle all its GUI in a platform-dependent manner. How well it will be
287 possible to do such a split remains to be seen. As I said, this is
288 highly experimental and just in its baby steps phase.
290 Technically, one important special aspect of iOS is that apps are not
291 allowed to load own dynamic libraries. (System libraries are used in
292 the form of dynamic libraries, just like on MacOSX, of which iOS is a
293 variant.) So all the libraries in LibreOffice that normally are shared
294 libraries (DLLs on Windows, shared objects (.so) on Linux, dynamic
295 libraries on MacOSX (.dylib)) need to be built as static archives
296 instead. Obviously this will have some interesting consequences for
297 how UNO is implemented and used. None of that has been spared much
298 thought yet.
300 The Apple tool-chain for iOS cross-building is available only for
301 MacOSX, so that is where I have been doing it.
303 Here is my autogen.lastrun for iOS (device):
304 CXX=ccache /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
305 CC=ccache /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
306 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0
307 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0
308 --with-distro=LibreOfficeiOS
309 --with-external-tar=/Volumes/ooo/git/master/src
310 --with-num-cpus=1
311 --with-max-jobs=1
313 And here for the iOS simulator:
314 CXX=ccache /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
315 CC=ccache /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
316 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0
317 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0
318 --with-distro=LibreOfficeiOS
319 --with-external-tar=/Volumes/ooo/git/master/src
320 --with-num-cpus=1
321 --with-max-jobs=1
322 --disable-librsvg
323 --enable-debug
326 Android
327 -------
329 I don't know much about Android, but from a technical point of view it
330 is a kind of Linux, of course. As far as I know it is allowed for an
331 Android app to use shared objects, but if it isn't, then just the same
332 approach as used on iOS will need to be used.
334 As for the GUI, the same holds as said above for iOS.
336 I have done my Android cross-compilation work on Linux (openSUSE in
337 particular), but it could as well be done on MacOSX. The Android
338 cross-buld tool-chain (the "Native Development Kit", or NDK) is
339 available for Linux, MacOSX and Windows. (Trying to cross-compile from
340 Windows will probably drive you insane.)
342 Here is my autogen.lastrun for Android:
343 SYSBASE=/home/tml/android-ndk-r6/platforms/android-9/arch-arm
344 CC=ccache /home/tml/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot /home/tml/android-ndk-r6/platforms/android-9/arch-arm
345 CXX=ccache /home/tml/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ --sysroot /home/tml/android-ndk-r6/platforms/android-9/arch-arm -I /home/tml/android-ndk-r6/sources/cxx-stl/gnu-libstdc++/include -I/home/tml/android-ndk-r6/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include -L/home/tml/android-ndk-r6/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a -fexceptions -frtti
346 AR=/home/tml/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
347 NM=/home/tml/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-nm
348 OBJDUMP=/home/tml/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-objdump
349 RANLIB=/home/tml/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ranlib
350 STRIP=/home/tml/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip
351 CC_FOR_BUILD=ccache gcc
352 CXX_FOR_BUILD=ccache g++
353 --build=x86_64-unknown-linux-gnu
354 --disable-zenity
355 --with-distro=LibreOfficeAndroid
356 --with-external-tar=/mnt/hemulen/ooo/git/master/src
357 --disable-python
358 --with-num-cpus=1
359 --with-max-jobs=1
360 --without-helppack-integration
361 --without-myspell-dicts
364 PowerPC Mac OS X
365 ----------------
367 Cross-compiling for PowerPC Mac OS X from Intel Mac OS X will probably
368 be easy. The APIs available should after all be closely identical to
369 those on Intel Mac OS X, and LibreOffice builds fine natively on
370 PowerPC Mac already. I have just started experimenting with it. My
371 autogen.lastrun looks like this:
373 CC=ccache /Xcode3/usr/bin/gcc-4.0 -arch ppc
374 CXX=ccache /Xcode3/usr/bin/g++-4.0 -arch ppc
375 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0
376 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0
377 --build=i386-apple-darwin10.7.0
378 --host=powerpc-apple-darwin10
379 --disable-mozilla
380 --disable-build-mozilla
381 --with-external-tar=/Volumes/ooo/git/master/src
385 That's all, thank you, and have a nice day. People with commit access,
386 feel free to edit this document, and add yourself below. Sorry for
387 writing now initially from such a personal point of view.
389 --Tor Lillqvist <tlillqvist@novell.com>, <tml@iki.fi>