Recent

Author Topic: [SOLVED]step-by-step guide how to set-up cross-compilation to Android correctly?  (Read 4561 times)

Eugene Loza

  • Hero Member
  • *****
  • Posts: 570
    • My "almost daily" development blog
Sorry... I know this is absolutely noobish question...
But I'm struggling 4 days to set up Android cross-compilation and still no results.

Debian:
I've successfully compiled NDK's example under Debian Linux and it works on my android tablet.
When I compile FPC-SRC for cross compilation to Android by
Code: [Select]
make clean crossall crossinstall OS_TARGET=android CPU_TARGET=arm CROSSOPT="-CfVFPV3" INSTALL_PREFIX=/usrneither I nor "whereis" can find the required ppcarm (only ppcrossarm is generated after compilation). And when I try to compile something to Android I get "Failed to execute "ppcarm", error code: 127".

Windows 7:
I install SDK and extract NDK.
Then I try to install fpc-3.0.0.i386-win32.cross.android.exe it prompts to select a path where Android NDK files are located. But when I point it to the NDK directory I get "unable to find NDK binutils for arm-linux-debiabi". I've tried every imaginable subfolder but the result is either the same error message or "Unable to find NDK library files".

Maybe there is a good step-by-step guide for fpc 3.0.0 where I can find the exact location of the libraries, or find out which installation/set-up step do I fail?
« Last Edit: October 06, 2016, 06:44:02 am by Eugene Loza »
Lazarus 1.9 + FPC 3.1.1 Debian Jessie 64 bit.

My Free and Open Source games in Lazarus/FreePascal/CastleGameEngine:
https://decoherence.itch.io/
(and some ancient games in Turbo Pascal too)
Sources are here: https://github.com/eugeneloza?tab=repositories

Handoko

  • Hero Member
  • *****
  • Posts: 4292
  • My goal: build my own game engine using Lazarus
Maybe it doesn't answer your question. But hope it may help.

My step-by-step cross compile to Android ARM:
01. cd /usr/share/fpcsrc/3.0.0
02. sudo make clean crossall OS_TARGET=android CPU_TARGET=arm
03. sudo make crossinstall OS_TARGET=android CPU_TARGET=arm INSTALL_PREFIX=/usr
04. sudo ln -sf /usr/lib/fpc/3.0.0/ppcrossarm /usr/bin/ppcrossarm
05. sudo ln -sf /usr/bin/ppcrossarm /usr/bin/ppcarm
06. Add these lines to /etc/fpc.cfg:
----------
#IFDEF ANDROID
#IFDEF CPUARM
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#ENDIF
----------

Note: tested on Ubuntu Mate 64-bit, Lazarus 1.6 + FPC 3.0.0
« Last Edit: May 09, 2016, 06:34:09 pm by Handoko »

Eugene Loza

  • Hero Member
  • *****
  • Posts: 570
    • My "almost daily" development blog
Thanks a lot, Handoko!
I'll give it a try as soon as possible. That seems to do the trick. I've missed 02 and 04-05 when I've tried to adapt the tutorial to my needs.
Lazarus 1.9 + FPC 3.1.1 Debian Jessie 64 bit.

My Free and Open Source games in Lazarus/FreePascal/CastleGameEngine:
https://decoherence.itch.io/
(and some ancient games in Turbo Pascal too)
Sources are here: https://github.com/eugeneloza?tab=repositories

Leledumbo

  • Hero Member
  • *****
  • Posts: 8344
  • Programming + Glam Metal + Tae Kwon Do = Me
neither I nor "whereis" can find the required ppcarm (only ppcrossarm is generated after compilation). And when I try to compile something to Android I get "Failed to execute "ppcarm", error code: 127".
ppcarm won't be generated, you're building a cross compiler, not native compiler. You can't have native compiler anyway, if your host system is not arm.
Maybe there is a good step-by-step guide for fpc 3.0.0 where I can find the exact location of the libraries, or find out which installation/set-up step do I fail?
Just continue from your previous step. The ppcrossarm has been generated, but not yet symlinked to the same directory as fpc (/usr/bin). After this you'll need to make arm-linux-as and arm-linux-ld, be it symlink (I prefer this) or pure copy, from the one in NDK directory (grab any gcc version, but in my experience 4.6 and 4.9 works the best for android JB - L, haven't got M for my device so I can't test, not sure about clang version, too lazy to try) to a /usr/bin or any other directory specified by -FD in your fpc.cfg. Last but not least, make sure -Fu in your fpc.cfg can point to arm-android directory of fpc toolchain you just built above.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 570
    • My "almost daily" development blog
FINALLY I'VE MADE IT  :D
The problem was in "ln -s ppcrossarm /usr/bin/ppcrossarm" creating broken symbolic links
"cd /usr/bin ***** ln -s /usr/lib/fpc/3.0.0/ppcrossarm ." was the only way I could do the things correctly. Now everything works as expected.
Thanks a lot for your help, friends!!!
« Last Edit: May 24, 2016, 04:31:49 am by Eugene Loza »
Lazarus 1.9 + FPC 3.1.1 Debian Jessie 64 bit.

My Free and Open Source games in Lazarus/FreePascal/CastleGameEngine:
https://decoherence.itch.io/
(and some ancient games in Turbo Pascal too)
Sources are here: https://github.com/eugeneloza?tab=repositories

 

TinyPortal © 2005-2018