Missing #endif
[LibreOffice.git] / README.cross
blob0df25a841920c57b107f1b8035bd97cff331cc1f
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 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
96 openSUSE_Factory.
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
115 missing dependency.
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
144 --disable-activex
145 --disable-binfilter
146 --disable-build-mozilla
147 --disable-directx
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
157 --disable-mozilla
158 --disable-nss-module
159 --disable-zenity
160 --enable-python=system
161 --with-external-tar=/mnt/hemulen/ooo/git/master/src
162 --with-num-cpus=1
163 --with-max-jobs=1
164 --with-system-altlinuxhyph
165 --with-system-boost
166 --with-system-cairo
167 --with-system-cppunit
168 --with-system-curl
169 --with-system-db
170 --with-system-expat
171 --with-system-gettext
172 --with-system-hunspell
173 --with-system-icu
174 --with-system-libpng
175 --with-system-libwpd
176 --with-system-libwpg
177 --with-system-libwps
178 --with-system-libxml
179 --with-system-libxslt
180 --with-system-lpsolve
181 --with-system-mythes
182 --with-system-neon
183 --with-system-openssl
184 --with-system-redland
185 --with-vendor=no
186 --without-help
187 --without-helppack-integration
188 --without-myspell-dicts
190 Once you have compiled it, you may want to try to run it:
192 $ cd /tmp
193 $ 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
194 $ cd LibO-Dev_OOO350m1_Win_x86_install-arc_en-US/LibO-dev\ 3.5/program
195 $ wine soffice.exe
197 NB. it is important to unpack somewhere low in the hierarchy structure (like
198 in /tmp as advised above), otherwise you'll get BerkeleyDB errors on startup.
200 And if you are brave enough, you can even debug it.  First you have to add the
201 URE dll's to the wine's PATH using 'wine regedit' - see
202 http://www.winehq.org/docs/wineusr-guide/environment-variables, and add
203 Z:\tmp\LibO-Dev_OOO350m1_Win_x86_install-arc_en-US\LibO-dev 3.5\URE\bin
204 to "Path" in My Computer->HKEY_CURRENT_USER->Environment.
206 Then run linkoo, so that when you rebuild something, you can directly see the
207 changes the next time you run it:
209 solenv/bin/linkoo '/tmp/LibO-Dev_OOO350m1_Win_x86_install-arc_en-US/LibO-dev 3.5' <your_clone_dir>
211 And start debugging:
213 $ winedbg soffice.bin
215 Would be great to be able to use winedbg --gdb, but it was crashing here :-( -
216 but maybe you'll be more lucky.
218 TODO:
220 - installation
221   - so far the make_installer.pl calls makecab.exe, uuidgen.exe, and
222     others; would be best to avoid that if at all possible (using a free
223     cab implementation, part of Wine or something)
224   - MSI generation
225   - if at all possible, the make dev-install installation (with links
226     back to the build) should be done so that it would be directly
227     executable via wine after doing make dev-install :-)
229 - runtime
230   - no idea if the entire thing works after the installation at all; I
231     suppose there will be runtime problems to look at too
233 - cleanup
234   - enable & fix pieces that are currently disabled
235     - --without-myspell-dicts
236     - --disable-directx
237     - --disable-activex
238     - --disable-mozilla
239   - much of the stuff currently relies on --with-system-*, and
240     consequently on the mingw32-* openSUSE packages; might be good to be
241     able to build with as few dependencies as possible - but that is low
242     prio I think
244 - profiling
245   - when all the above is sorted out, we should look at the speed of
246     this vs. the speed of the MSVC version
252 iOS is the operating system of Apple's mobile devices. Clearly for a
253 device like the iPad it would be totally unacceptable to run a normal
254 LibreOffice application with a overlapping windows and mouse-oriented
255 GUI widgets. No work has been done (at least publicly) to design a
256 touch GUI for LibreOffice, so the work on cross-compiling LibreOffice
257 for iOS is extremely experimental, and of course partly pointless;)
258 But it is interesting and fun nonetheless.
260 Obviously it will make sense to build only a part of LibreOffice's
261 code for iOS. Most likely all GUI-oriented code should be left out,
262 and some iOS app that eventually wants to use the remaining bits will
263 handle all its GUI in a platform-dependent manner. How well it will be
264 possible to do such a split remains to be seen. As I said, this is
265 highly experimental and just in its baby steps phase.
267 Technically, one important special aspect of iOS is that apps are not
268 allowed to load own dynamic libraries. (System libraries are used in
269 the form of dynamic libraries, just like on Mac OS X, of which iOS is a
270 variant.) So all the libraries in LibreOffice that normally are shared
271 libraries (DLLs on Windows, shared objects (.so) on Linux, dynamic
272 libraries on Mac OS X (.dylib)) need to be built as static archives
273 instead. Obviously this will have some interesting consequences for
274 how UNO is implemented and used. None of that has been spared much
275 thought yet.
277 The Apple tool-chain for iOS cross-building is available only for
278 Mac OS X, so that is where I have been doing it.
280 Here is my autogen.lastrun for iOS (device):
281 CXX=ccache /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++ -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
282 CC=ccache /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
283 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0 -mmacosx-version-min=10.4
284 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0 -mmacosx-version-min=10.4
285 --with-distro=LibreOfficeiOS
286 --with-external-tar=/Volumes/ooo/git/master/src
287 --with-num-cpus=1
288 --with-max-jobs=1
289 --without-help
290 --without-helppack-integration
291 --without-myspell-dicts
293 And here for the iOS simulator:
294 CXX=ccache /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++ -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
295 CC=ccache /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
296 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0 -mmacosx-version-min=10.4
297 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0 -mmacosx-version-min=10.4
298 --with-distro=LibreOfficeiOS
299 --with-external-tar=/Volumes/ooo/git/master/src
300 --with-num-cpus=1
301 --with-max-jobs=1
302 --enable-debug
303 --without-help
304 --without-helppack-integration
305 --without-myspell-dicts
307 It seems that with the latest iOS SDK one has to do:
308 sudo ln -s i686-apple-darwin10 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/include/c++/4.2.1/i686-apple-darwin11
309 or g++ won't find its headers like <bits/c++config.h>
311 Android
312 -------
314 I don't know much about Android, but from a technical point of view it
315 is a kind of Linux, of course. As far as I know it is allowed for an
316 Android app to use shared objects, but if it isn't, then just the same
317 approach as used on iOS will need to be used.
319 As for the GUI, the same holds as said above for iOS.
321 I have done my Android cross-compilation work on Linux (openSUSE in
322 particular) and Mac OS X. The Android cross-buld tool-chain (the
323 "Native Development Kit", or NDK) is available for Linux, Mac OS X and
324 Windows. (Trying to cross-compile from Windows will probably drive you
325 insane.)
327 Here is my autogen.lastrun for Android:
328 SYSBASE=/home/tml/android-ndk-r6b/platforms/android-9/arch-arm
329 CC=ccache /home/tml/android-ndk-r6b/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-r6b/platforms/android-9/arch-arm
330 CXX=ccache /home/tml/android-ndk-r6b/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-r6b/platforms/android-9/arch-arm -I /home/tml/android-ndk-r6b/sources/cxx-stl/gnu-libstdc++/include -I/home/tml/android-ndk-r6b/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include -L/home/tml/android-ndk-r6b/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a -fexceptions -frtti
331 AR=/home/tml/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
332 NM=/home/tml/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-nm
333 OBJDUMP=/home/tml/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-objdump
334 RANLIB=/home/tml/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ranlib
335 STRIP=/home/tml/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip
336 CC_FOR_BUILD=ccache gcc
337 CXX_FOR_BUILD=ccache g++
338 --build=x86_64-unknown-linux-gnu
339 --disable-zenity
340 --with-distro=LibreOfficeAndroid
341 --with-external-tar=/mnt/hemulen/ooo/git/master/src
342 --disable-python
343 --with-num-cpus=1
344 --with-max-jobs=1
345 --without-helppack-integration
346 --without-myspell-dicts
349 PowerPC Mac OS X
350 ----------------
352 Cross-compiling for PowerPC Mac OS X from Intel Mac OS X will probably
353 be easy. The APIs available should after all be closely identical to
354 those on Intel Mac OS X, and LibreOffice builds fine natively on
355 PowerPC Mac already. I have just started experimenting with it. My
356 autogen.lastrun looks like this:
358 CC=ccache /Xcode3/usr/bin/gcc-4.0 -arch ppc
359 CXX=ccache /Xcode3/usr/bin/g++-4.0 -arch ppc
360 CC_FOR_BUILD=ccache /Xcode3/usr/bin/gcc-4.0
361 CXX_FOR_BUILD=ccache /Xcode3/usr/bin/g++-4.0
362 --build=i386-apple-darwin10.7.0
363 --host=powerpc-apple-darwin10
364 --disable-mozilla
365 --disable-build-mozilla
366 --with-external-tar=/Volumes/ooo/git/master/src
370 That's all, thank you, and have a nice day. People with commit access,
371 feel free to edit this document, and add yourself below. Sorry for
372 writing now initially from such a personal point of view.
374 --Tor Lillqvist <tlillqvist@novell.com>, <tml@iki.fi>