Recent

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

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
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 »
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • 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: 678
    • My games in Pascal
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.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • 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: 678
    • My games in Pascal
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 »
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

 

TinyPortal © 2005-2018