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
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
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.
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
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
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
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 openSUSE and SLE. Personally I use the mingw32 packages in the Open
87 Build Service, running on openSUSE:
89 http://download.opensuse.org/repositories/windows:/mingw:/win32/
91 For example, you can install it like this:
93 zypper ar http://download.opensuse.org/repositories/windows:/mingw:/win32/<your_os>/windows:mingw:win32.repo
95 where <your_os> is one of SLE_11, SLE_11_SP1, openSUSE_11.3, openSUSE_11.4 or
98 zypper in mingw32-cross-gcc mingw32-cross-gcc-c++ mingw32-python-devel \
99 mingw32-libexpat-devel mingw32-libexpat mingw32-boost-devel \
100 mingw32-libhyphen-devel mingw32-libhyphen mingw32-hyphen-en \
101 mingw32-liblpsolve mingw32-liblpsolve-devel \
102 mingw32-libxml2-devel mingw32-libxslt-devel mingw32-libicu \
103 mingw32-libicu-devel mingw32-libgraphite2 mingw32-libgraphite2-devel \
104 mingw32-libcairo2 mingw32-cairo-devel mingw32-librsvg mingw32-librsvg-devel \
105 mingw32-hunspell mingw32-hunspell-devel mingw32-libcurl \
106 mingw32-libcurl-devel mingw32-libneon mingw32-libneon-devel \
107 mingw32-libopenssl mingw32-libopenssl-devel mingw32-libexttextcat \
108 mingw32-libexttextcat-devel mingw32-libdb mingw32-libdb-devel \
109 mingw32-cross-pkg-config mingw32-pkg-config mingw32-libcppunit \
110 mingw32-libcppunit-devel mingw32-libredland mingw32-libredland-devel \
111 mingw32-libmythes mingw32-libmythes-devel
113 There might be more that are missing, please read carefully what autogen.sh
114 tells you, and either remove one of the --with-system-*, or install the
117 It also looks like graphite2.pc needs tweaking in order to work right; but
118 that's likely to be fixed in the openSUSE project.
120 It is somewhat unclear how well thought-out the conditionals and code
121 for MinGW inside the OOo-originated code in LibreOffice actually
122 are. What I have noticed of it seems a bit randomish, with
123 copy-pasting having been preferred to factoring out differences.
125 Most of the configuration settings are maintained in the LibreOfficeMinGW
126 distro-config, so in your autogen.lastrun, you can use:
128 CC=ccache i686-w64-mingw32-gcc
129 CXX=ccache i686-w64-mingw32-g++
130 CC_FOR_BUILD=ccache gcc
131 CXX_FOR_BUILD=ccache g++
132 --with-distro=LibreOfficeMinGW
134 Alternatively, you can use something like the following; but the preferred way
135 is to keep LibreOfficeMinGW distro up-to-date.
137 CC=ccache i686-w64-mingw32-gcc
138 CXX=ccache i686-w64-mingw32-g++
139 CC_FOR_BUILD=ccache gcc
140 CXX_FOR_BUILD=ccache g++
141 --build=x86_64-unknown-linux-gnu
142 --host=i686-w64-mingw32
143 --with-distro=LibreOfficeWin32
146 --disable-build-mozilla
148 --disable-ext-nlpsolver
149 --disable-ext-pdfimport
150 --disable-ext-presenter-console
151 --disable-ext-presenter-minimizer
152 --disable-ext-report-builder
153 --disable-ext-scripting-beanshell
154 --disable-ext-scripting-javascript
155 --disable-ext-wiki-publisher
156 --disable-ext-wiki-publisher
160 --enable-python=system
161 --with-external-tar=/mnt/hemulen/ooo/git/master/src
164 --with-system-altlinuxhyph
167 --with-system-cppunit
171 --with-system-gettext
172 --with-system-hunspell
179 --with-system-lpsolve
182 --with-system-openssl
183 --with-system-redland
186 --without-helppack-integration
187 --without-myspell-dicts
189 Once you have compiled it, you may want to try to run it:
192 $ 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
193 $ cd LibO-Dev_OOO350m1_Win_x86_install-arc_en-US/LibO-dev\ 3.5/program
196 NB. it is important to unpack somewhere low in the hierarchy structure (like
197 in /tmp as advised above), otherwise you'll get BerkeleyDB errors on startup.
199 And if you are brave enough, you can even debug it. First you have to add the
200 URE dll's to the wine's PATH using 'wine regedit' - see
201 http://www.winehq.org/docs/wineusr-guide/environment-variables, and add
202 Z:\tmp\LibO-Dev_OOO350m1_Win_x86_install-arc_en-US\LibO-dev 3.5\URE\bin
203 to "Path" in My Computer->HKEY_CURRENT_USER->Environment.
205 Then run linkoo, so that when you rebuild something, you can directly see the
206 changes the next time you run it:
208 solenv/bin/linkoo '/tmp/LibO-Dev_OOO350m1_Win_x86_install-arc_en-US/LibO-dev 3.5' <your_clone_dir>
212 $ winedbg soffice.bin
214 Would be great to be able to use winedbg --gdb, but it was crashing here :-( -
215 but maybe you'll be more lucky.
220 - so far the make_installer.pl calls makecab.exe, uuidgen.exe, and
221 others; would be best to avoid that if at all possible (using a free
222 cab implementation, part of Wine or something)
224 - if at all possible, the make dev-install installation (with links
225 back to the build) should be done so that it would be directly
226 executable via wine after doing make dev-install :-)
229 - no idea if the entire thing works after the installation at all; I
230 suppose there will be runtime problems to look at too
233 - enable & fix pieces that are currently disabled
234 - --without-myspell-dicts
238 - much of the stuff currently relies on --with-system-*, and
239 consequently on the mingw32-* openSUSE packages; might be good to be
240 able to build with as few dependencies as possible - but that is low
244 - when all the above is sorted out, we should look at the speed of
245 this vs. the speed of the MSVC version
251 iOS is the operating system of Apple's mobile devices. Clearly for a
252 device like the iPad it would be totally unacceptable to run a normal
253 LibreOffice application with a overlapping windows and mouse-oriented
254 GUI widgets. No work has been done (at least publicly) to design a
255 touch GUI for LibreOffice, so the work on cross-compiling LibreOffice
256 for iOS is extremely experimental, and of course partly pointless;)
257 But it is interesting and fun nonetheless.
259 Obviously it will make sense to build only a part of LibreOffice's
260 code for iOS. Most likely all GUI-oriented code should be left out,
261 and some iOS app that eventually wants to use the remaining bits will
262 handle all its GUI in a platform-dependent manner. How well it will be
263 possible to do such a split remains to be seen. As I said, this is
264 highly experimental and just in its baby steps phase.
266 Technically, one important special aspect of iOS is that apps are not
267 allowed to load own dynamic libraries. (System libraries are used in
268 the form of dynamic libraries, just like on Mac OS X, of which iOS is a
269 variant.) So all the libraries in LibreOffice that normally are shared
270 libraries (DLLs on Windows, shared objects (.so) on Linux, dynamic
271 libraries on Mac OS X (.dylib)) need to be built as static archives
272 instead. Obviously this will have some interesting consequences for
273 how UNO is implemented and used. None of that has been spared much
276 The Apple tool-chain for iOS cross-building is available only for
277 Mac OS X, so that is where I have been doing it.
279 Here is my autogen.lastrun for iOS (device):
280 CXX=ccache /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++ -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
281 CC=ccache /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
282 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0 -mmacosx-version-min=10.4
283 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0 -mmacosx-version-min=10.4
284 --with-distro=LibreOfficeiOS
285 --with-external-tar=/Volumes/ooo/git/master/src
289 --without-helppack-integration
290 --without-myspell-dicts
292 And here for the iOS simulator:
293 CXX=ccache /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++ -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk
294 CC=ccache /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk
295 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0 -mmacosx-version-min=10.4
296 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0 -mmacosx-version-min=10.4
297 --with-distro=LibreOfficeiOS
298 --with-external-tar=/Volumes/ooo/git/master/src
303 --without-helppack-integration
304 --without-myspell-dicts
306 It seems that with the latest iOS SDK one has to do:
307 sudo ln -s i686-apple-darwin10 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/include/c++/4.2.1/i686-apple-darwin11
308 or g++ won't find its headers like <bits/c++config.h>
313 I don't know much about Android, but from a technical point of view it
314 is a kind of Linux, of course. As far as I know it is allowed for an
315 Android app to use shared objects, but if it isn't, then just the same
316 approach as used on iOS will need to be used.
318 As for the GUI, the same holds as said above for iOS.
320 I have done my Android cross-compilation work on Linux (openSUSE in
321 particular) and Mac OS X. The Android cross-buld tool-chain (the
322 "Native Development Kit", or NDK) is available for Linux, Mac OS X and
323 Windows. (Trying to cross-compile from Windows will probably drive you
326 Here is my autogen.lastrun for Android:
327 SYSBASE=/home/tml/android-ndk-r7/platforms/android-9/arch-arm
328 CC=ccache /home/tml/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc -march=armv7-a -mfloat-abi=softfp -mthumb -mfpu=neon -Wl,--fix-cortex-a8 --sysroot /home/tml/android-ndk-r7/platforms/android-9/arch-arm -L/home/tml/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a
329 CXX=ccache /home/tml/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ -march=armv7-a -mfloat-abi=softfp -mthumb -mfpu=neon -Wl,--fix-cortex-a8 --sysroot /home/tml/android-ndk-r7/platforms/android-9/arch-arm -I /home/tml/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/include -I/home/tml/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include -L/home/tml/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a -fexceptions -frtti
330 AR=/home/tml/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
331 NM=/home/tml/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-nm
332 OBJDUMP=/home/tml/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-objdump
333 RANLIB=/home/tml/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ranlib
334 STRIP=/home/tml/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip
335 CC_FOR_BUILD=ccache gcc
336 CXX_FOR_BUILD=ccache g++
337 --build=x86_64-unknown-linux-gnu
339 --with-distro=LibreOfficeAndroid
340 --with-external-tar=/mnt/hemulen/ooo/git/master/src
344 --without-helppack-integration
345 --without-myspell-dicts
351 Cross-compiling for PowerPC Mac OS X from Intel Mac OS X will probably
352 be easy. The APIs available should after all be closely identical to
353 those on Intel Mac OS X, and LibreOffice builds fine natively on
354 PowerPC Mac already. I have just started experimenting with it. My
355 autogen.lastrun looks like this:
357 CC=ccache /Xcode3/usr/bin/gcc-4.0 -arch ppc
358 CXX=ccache /Xcode3/usr/bin/g++-4.0 -arch ppc
359 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0
360 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0
361 --build=i386-apple-darwin10.7.0
362 --host=powerpc-apple-darwin10
364 --disable-build-mozilla
365 --with-external-tar=/Volumes/ooo/git/master/src
369 That's all, thank you, and have a nice day. People with commit access,
370 feel free to edit this document, and add yourself below. Sorry for
371 writing now initially from such a personal point of view.
373 --Tor Lillqvist <tlillqvist@novell.com>, <tml@iki.fi>