Forum > Android

Lazarus for Android


I started to study to develop Android applications in Lazarus IDE.

I'm following the tutorial:

But I don't get sucess to compile cross-platform.

I'm using Windows, with "Lazarus fpc 2.4.4 win32".
I've downloaded Android SDK and NDK, ok.

I don't understand the step 2 and 3: Why download FPC 2.5.1 and then use FPC 2.4.4 ???
And then, in the "build.bat", the "make.exe" utility recuses "crossinstall" parameter.

I've tested the "Devel Linux Image - Virtual Box" and it work's fine for Android compilation, but I would like to use directly in my Windows section.

What I am doing wrong ?

The part of tutorial:

--- Quote ---Building the compiler yourself in Windows

Step 1 - Install the Android SDK and NDK
Download from Google and install both the SDK and the NDK for Windows.
Check your path to the binutils installed by the NDK. For example, for NDK r7 installed in C:\Programas\android-ndk-r7\ the path is C:\Programas\android-ndk-r7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin
Also check your path to the libraries installed by the NDK. For example, for NDK r7 installed in C:\Programas\android-ndk-r7\ the path is C:\Programas\android-ndk-r7\platforms\android-8\arch-arm\usr

Step 2 - Download FPC 2.5.1 from January 19th
Create a folder to store the FPC trunk source code and checkout revision 16790

Step 3 - Install FPC 2.4.4
An easy way to obtain a good FPC 2.4.4 is installing Lazarus For example, let's say you install this Lazarus version in C:\Programas\lazarusfpc244

Step 4 - Create the build script and built it
Create the output directory, for example: C:\Programas\fpcandroid\output
Next create a file called build.bat in the fpc root folder, in our example C:\Programas\fpcandroid and copy to it:
SET PATH=C:\Programas\lazarusfpc244\fpc\2.4.4\bin\i386-win32\
make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=C:\Programas\android-ndk-r7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin OPT=-dFPC_ARMEL BINUTILSPREFIX=arm-linux-androideabi- INSTALL_PREFIX=C:\Programas\fpcandroid\output
Next run this batch script and you should have FPC installed into C:\Programas\fpcandroid\output

Step 5 - Copy some cross-binutils into the bin dir
You now should have a FPC binary in C:\Programas\fpcandroid\output\bin\i386-win32
Now get these 3 files:
C:\Programas\android-ndk-r7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-as.exe C:\Programas\android-ndk-r7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-ld.exe C:\Programas\android-ndk-r7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-strip.exe
And copy and then rename to have:
C:\Programas\fpcandroid\output\bin\i386-win32\arm-linux-as.exe C:\Programas\fpcandroid\output\bin\i386-win32\arm-linux-ld.exe C:\Programas\fpcandroid\output\bin\i386-win32\arm-linux-strip.exe

Step 6 - Merge this into a Lazarus FPC setup
Let's say you have the following Lazarus C:\Programas\lazarus31 with the following fpc installed inside it: C:\Programas\lazarus31\fpc\2.5.1\bin\i386-win32 and C:\Programas\lazarus31\fpc\2.5.1\units\
Now copy C:\Programas\fpcandroid\output\units\arm-linux to C:\Programas\lazarus31\fpc\2.5.1\units\
Now copy all .exe files from C:\Programas\fpcandroid\output\bin\i386-win32\ into C:\Programas\lazarus31\fpc\2.5.1\bin\i386-win32
Now you can already build the example project androidlcltest.lpi using the Windows-Release build mode
--- End quote ---

Hello, please always post about Android in the Android section. I havent seen your post till today because it was burried in the "General" section where lots of people post =)

About your questions: The golden rule for FPC building is always use the latest release to build something (considering from the point in time of a given codebase), so to build FPC 2.5.1 you need FPC 2.4.4 no other combination at all is tested or guaranteed to work or give a sane result.

Also, do you have correct paths in your build.bat?


[0] Message Index

Go to full version