Forum > Beginners
[SOLVED]step-by-step guide how to set-up cross-compilation to Android correctly?
(1/1)
Eugene Loza:
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: ---make clean crossall crossinstall OS_TARGET=android CPU_TARGET=arm CROSSOPT="-CfVFPV3" INSTALL_PREFIX=/usr
--- End code ---
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".
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?
Handoko:
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
Eugene Loza:
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.
Leledumbo:
--- Quote from: Eugene Loza on May 09, 2016, 05:34:05 pm ---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".
--- End quote ---
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.
--- Quote from: Eugene Loza on May 09, 2016, 05:34:05 pm ---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?
--- End quote ---
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:
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!!!
Navigation
[0] Message Index