Building Spring Cross Compiled: Difference between revisions
mNo edit summary |
adding kind of a stub for SCons |
||
| Line 1: | Line 1: | ||
Cross-compiling allows you to build for other platforms than the machine you are building on. You can, for example, compile Windows 32-bit binaries on a Linux 64-bit machine. | |||
= CMake cross compiling = | |||
== Setting up the cross compiler == | == Setting up the cross compiler == | ||
| Line 103: | Line 103: | ||
** doing "make install DESTDIR=/some/path" will install spring in the specified place, putting files in subdirectories like configured. This may be helpfull when making packages so spring don'T get installed on your system for real (see also CMake FAQ [[http://www.vtk.org/Wiki/CMake_FAQ#Does_CMake.27s_.22make_install.22_support_DESTDIR.3F]]). | ** doing "make install DESTDIR=/some/path" will install spring in the specified place, putting files in subdirectories like configured. This may be helpfull when making packages so spring don'T get installed on your system for real (see also CMake FAQ [[http://www.vtk.org/Wiki/CMake_FAQ#Does_CMake.27s_.22make_install.22_support_DESTDIR.3F]]). | ||
** You need to update the mime database (update-mime-database) and the kde database (kbuildsycoca) after installing to make the system aware of the newly installed mime types and desktop shortcuts. | ** You need to update the mime database (update-mime-database) and the kde database (kbuildsycoca) after installing to make the system aware of the newly installed mime types and desktop shortcuts. | ||
= SCons cross compiling = | |||
configure: | |||
<pre> | |||
MINGDIR=/usr/i586-mingw32msvc \ | |||
MINGWLIBS=${MINGWLIBS_DIR} \ | |||
CC=i586-mingw32msvc-gcc \ | |||
CXX=i586-mingw32msvc-g++ \ | |||
scons configure platform=windows debug=DEBUG2 \ | |||
mingwlibsdir=${MINGWLIBS_DIR} \ | |||
builddir="${BUILD_DIR}" \ | |||
prefix="${INSTALL_DIR}" \ | |||
datadir="." \ | |||
bindir="." \ | |||
libdir="." | |||
</pre> | |||
make install: | |||
<pre> | |||
MINGDIR=/usr/i586-mingw32msvc \ | |||
CC=i586-mingw32msvc-gcc \ | |||
CXX=i586-mingw32msvc-g++ \ | |||
scons install \ | |||
builddir="${BUILD_DIR}" | |||
</pre> | |||
Revision as of 13:50, 9 February 2009
Cross-compiling allows you to build for other platforms than the machine you are building on. You can, for example, compile Windows 32-bit binaries on a Linux 64-bit machine.
CMake cross compiling
Setting up the cross compiler
I have only done this on Gentoo (instructions here or here).
There is also a general cross-compiler for linux here
Getting Spring's libraries
If Win32 (mingw32) is your target: Auswaschbar has helpfully uploaded all win32 dependencies here. Unpack with 7zip to a directory of your choice (or use the one I recommend below).
Setting up your directories
Here is my recommended layout
~/spring-xcompile/ (or wherever you want to put it all) ___ spring/ (the spring source) ___ win32/ (your target platform) _______ build/ (the build files for your target will go here) _______ final/ (the compiled binaries and libs will be installed here) _______ libs/ (the target libraries you just downloaded, ie: mingw32libs_v13) _______ win32.cmake (see below)
Create your cmake toolchain
- Create the toolchain file:
>> pico "~/spring-xcompile/win32/win32.cmake"
Example toolchain file
An example should be self-explanatory:
# the name of the target operating system SET(CMAKE_SYSTEM_NAME Windows) # which compilers to use for C and C++ SET(CMAKE_C_COMPILER i686-mingw32-gcc) SET(CMAKE_CXX_COMPILER i686-mingw32-g++) # here is the target environment located SET(CMAKE_FIND_ROOT_PATH /usr/i686-mingw32) # the spring mingw32 dependencies SET(MINGWLIBS ~/spring-xcompile/win32/libs) # the path that make install will use to put the final binaries SET(CMAKE_INSTALL_PREFIX ~/spring-xcompile/win32/final)
Pass this with "-DCMAKE_TOOLCHAIN_FILE=~/spring-xcompile/win32/win32.cmake" to cmake or select it in the gui to make a cross-compilation (see below).
Some Options Explained
- MINGWLIBS: directory where the MinGW library package is (only needed when compiling with mingw)
- CMAKE_BUILD_TYPE: either RELEASE, DEBUG, DEBUG2, DEBUG3 which compiler options to use
- CMAKE_INSTALL_PREFIX: installation prefix (defaults to /usr/local) defines the base directory for installing
- DATADIR, LIBDIR, BINDIR: where to install data, libraries or binaries (relative paths are based on CMAKE_INSTALL_PREFIX, absolute paths are absolute (DESTDIR is still respected))
- APPLICATIONS_DIR, MIME_DIR, PIXMAPS_DIR: where to install freedesktop-files (icons, mime-types and application-description)
Further reference
Run CMake
The GUI method
CMake offers a nice Qt4 gui to ease the following steps (to use the gui explained here, cmake must be at least version 2.6.1). Doing so should be straightforward:
- select source directory
- select (and/or create) build directory where temporary files are stored
- hit configure button
- choose your build type:
- Unix makefile if you are using linux and want to compile linux executables
- mingw makefiles if you are working on windows
- Unix makefile with cross compiler setup to cross-compile mingw32 executables, you have to select the toolchain file you want to use (see below)
- configure variables to your need (move the mouse over the options and read the tooltip for further informations on them and or see Section "Options")
- push generate button
- open commandline and do "make" and "make install"
The commandline method
- cd to build directory
>> cd ~user/spring-xcompile/win32/build
- "cmake <path to source tree> <options>" where:
- <path to source tree> is the path to the spring source directory
- <options> are defined like "-D<option name>=<value>
- IMPORTANT: depending on your settings you may need to run this command twice. It can't hurt so I recommend doing it anyway.
>> cmake "~user/spring-xcompile/spring" "-DCMAKE_TOOLCHAIN_FILE=~user/spring-xcompile/win32/win32.cmake"
- run "make" and "make install"
>> make && make install DESTDIR=~user/spring-xcompile/win32/final
Package Maintainers Note:
- doing "make install DESTDIR=/some/path" will install spring in the specified place, putting files in subdirectories like configured. This may be helpfull when making packages so spring don'T get installed on your system for real (see also CMake FAQ [[3]]).
- You need to update the mime database (update-mime-database) and the kde database (kbuildsycoca) after installing to make the system aware of the newly installed mime types and desktop shortcuts.
SCons cross compiling
configure:
MINGDIR=/usr/i586-mingw32msvc \
MINGWLIBS=${MINGWLIBS_DIR} \
CC=i586-mingw32msvc-gcc \
CXX=i586-mingw32msvc-g++ \
scons configure platform=windows debug=DEBUG2 \
mingwlibsdir=${MINGWLIBS_DIR} \
builddir="${BUILD_DIR}" \
prefix="${INSTALL_DIR}" \
datadir="." \
bindir="." \
libdir="."
make install:
MINGDIR=/usr/i586-mingw32msvc \
CC=i586-mingw32msvc-gcc \
CXX=i586-mingw32msvc-g++ \
scons install \
builddir="${BUILD_DIR}"