Difference between revisions of "Android"

From Lazarus wiki
(category)
Line 25: Line 25:
 
== Building cross compiler ==
 
== Building cross compiler ==
  
You need to have working FPC 2.6.x compiler in order to create the cross-compiler. This tutorial describes how to build the cross-compiler on Windows, but it can be used for any system with small obvious modifications.
+
You need to have working installation of FPC 2.6.x compiler in order to create the cross-compiler. This tutorial describes how to build the cross-compiler on Windows, but it can be used for any system with small obvious modifications.
  
 
Assume the following paths:
 
Assume the following paths:
* Android NDK path: '''<tt>C:\Program Files\Android SDK\android-ndk-r8d</tt>'''
+
* Android NDK path: <code>C:\Program Files\Android SDK\android-ndk-r8d</code>
* FPC svn sources path: '''<tt>C:\Develop\FPC\FPC</tt>'''
+
* FPC svn sources path: <code>C:\Develop\FPC\FPC</code>
* The cross-compiler installation path: '''<tt>C:\Develop\FPC\pp</tt>'''
+
* The cross-compiler installation path: <code>C:\Develop\FPC\pp</code>
  
 +
Add path to Android binutils to the PATH environment variable. In this tutorial the path is
 +
<code>C:\Program Files\Android SDK\android-ndk-r8d\toolchains\arm-linux-androideabi-4.7\prebuilt\windows\bin</code>
 +
 +
First you need to build the latest version of the fmcmake support program.
 +
To do that cd to the following folder:
 +
<code>C:\Develop\FPC\FPC\utils\fpcm\fpcmake</code>
 +
Then execute the command: <code>make</code>
 +
 +
Now cd to the root of FPC sources folder:
 +
<code>C:\Develop\FPC\FPC</code>
 +
 +
Execute the following command:
 +
 +
<code>make clean all install OS_TARGET=android CPU_TARGET=arm CROSSOPT="-O2 -g-" CROSSINSTALL=1 INSTALL_PREFIX=C:\Develop\FPC\pp FPCMAKE=C:\Develop\FPC\FPC\utils\fpcm\fpcmake</code>
 +
 +
After that you should have the cross-compiler and units installed in folder <code>C:\Develop\FPC\pp</code>
 +
Now create a new <code>fpc.cfg</code> file in folder <code>C:\Develop\FPC\pp\bin\i386-win32</code> and paste into it the following text:
 +
 +
<code>
 +
-Fu/Develop/FPC/pp/units/$FPCTARGET/*
 +
 +
#ifdef android
 +
#ifdef cpuarm
 +
-FlC:\Program Files\Android SDK\android-ndk-r8d\platforms\android-14\arch-arm\usr\lib
 +
#endif
 +
#endif
 +
</code>
 +
 +
 
[[Category:Android]]
 
[[Category:Android]]

Revision as of 19:09, 13 February 2013

Android

Currently support for android target is present in the trunk (development) version 2.7.1 of FPC.

Supported CPUs:

  • ARM
  • i386

Android NDK

You need to download and install Android NDK in order to compile programs for the android target. Download Android NDK using this link: http://developer.android.com/tools/sdk/ndk/index.html

Extract it to some folder.

FPC sources

Check out the latest trunk sources of FPC using the following command:

svn co FPC http://svn.freepascal.org/svn/fpc/trunk

Now you have the compiler sources in the FPC sub-folder.

Building cross compiler

You need to have working installation of FPC 2.6.x compiler in order to create the cross-compiler. This tutorial describes how to build the cross-compiler on Windows, but it can be used for any system with small obvious modifications.

Assume the following paths:

  • Android NDK path: C:\Program Files\Android SDK\android-ndk-r8d
  • FPC svn sources path: C:\Develop\FPC\FPC
  • The cross-compiler installation path: C:\Develop\FPC\pp

Add path to Android binutils to the PATH environment variable. In this tutorial the path is C:\Program Files\Android SDK\android-ndk-r8d\toolchains\arm-linux-androideabi-4.7\prebuilt\windows\bin

First you need to build the latest version of the fmcmake support program. To do that cd to the following folder: C:\Develop\FPC\FPC\utils\fpcm\fpcmake Then execute the command: make

Now cd to the root of FPC sources folder: C:\Develop\FPC\FPC

Execute the following command:

make clean all install OS_TARGET=android CPU_TARGET=arm CROSSOPT="-O2 -g-" CROSSINSTALL=1 INSTALL_PREFIX=C:\Develop\FPC\pp FPCMAKE=C:\Develop\FPC\FPC\utils\fpcm\fpcmake

After that you should have the cross-compiler and units installed in folder C:\Develop\FPC\pp Now create a new fpc.cfg file in folder C:\Develop\FPC\pp\bin\i386-win32 and paste into it the following text:

-Fu/Develop/FPC/pp/units/$FPCTARGET/*

  1. ifdef android
  2. ifdef cpuarm

-FlC:\Program Files\Android SDK\android-ndk-r8d\platforms\android-14\arch-arm\usr\lib

  1. endif
  2. endif