[SOLVD] Android executable not starting lazarus / 43-Android ---------------------------------------------------------------------- hinst · 2014-05-02 09:04 Another Android-related question if u excuse me: I am currently "hacking" on my old Android tablet. I have root access, also SSH access from PC. I also have busybox and bash shell installed. Everything works so far. I can launch executables from /system/bin like this: Code: [Select]bash-3.2# /system/bin/run-as Usage: run-as [] Have no idea what it does, but it works. Then I compiled FPC program like this: Code: [Select]program TestMinimalP; begin   WriteLN('Hello bucket'); end. Code: [Select]D:\Dev\daemonirc\SrcTest>D:\LA\FPC\bin\i386-win32\fpc.exe -Parm -Tandroid -CpARMv3 -CfSOFT -o..\Bin\arm-android\testminimalp -FU..\Units\arm-android\TestMinimalP TestMinimalP.lpr Free Pascal Compiler version 2.7.1 [2014/05/02] for arm Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Android for ARMEL Compiling TestMinimalP.lpr Assembling testminimalp Linking ..\Bin\arm-android\testminimalp 6 lines compiled, 2.5 secIt compiled successfully. Then I copied it to /system/bin folder of my tablet, then changed permissions, then tried to launch it. It says: no such file or directory Code: [Select]bash-3.2# /system/bin/testminimalp bash: /system/bin/testminimalp: No such file or directory But if I examine it with ls command, then it appears to be present: Code: [Select]bash-3.2# ls -l /system/bin/testminimalp -rwxrwxrwx system   root          26423 2014-05-02 12:55 testminimalpIt is present, and all permissions are enabled. Then why does it not want to launch it? I tried to find out why on my own, and here is what I found: if I copy some executable from my tablet to my PC, then examine it with file command, I get: Code: [Select]hinst@h-home-pc /cygdrive/d/Dev/daemonirc/Bin/arm- android $ file run-as run-as: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedIf I examine my executable, I get: Code: [Select]hinst@h-home-pc /cygdrive/d/Dev/daemonirc/Bin/arm- android $ file TestMinimalP TestMinimalP: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), strippedThe only difference I see is: file reports run-as to be statically linked, while my executable is kind of dynamically linked. I have no idea what are those libraries, but I currently believe that this is the reason why my executable does not work on my Android tablet. So how do I make FPC link those libraries statically? P.S: but something tells me that this is not the reason. Then why does it not work? P.P.S: I would really appreciate if someone could help me with this. The funny thing is: that it worked before. I tried launching executables generated by FPC from console emulator on my phone, and it worked. Why it does not work now I have no idea, I am now suspecting that someone broke it (on FPC side) P.S.#4: I googled some info, some ppl say that this error is related to libld.so library which is not present on Android. Indeed I opened my executable in text editor and searched for ".so" found libld.so surrounded by garbage not displayable as text obviously. libld.so is not present on Android, instead there's /system/bin/linker file ---------------------------------------------------------------------- hinst · 2014-05-03 07:26 Okay, I sort of solved it: http://stackoverflow.com/questions/8610103/how-do-you-cross-compile- elf-executables-for-android Should pass this option to linker to make it work: --dynamic-linker=/system/bin/linker For FPC: -k--dynamic-linker=/system/bin/linker Did this and it started working, got "Hello bucket" printed lol ---------------------------------------------------------------------- Leledumbo · 2014-05-03 10:38 QuoteShould pass this option to linker to make it work: --dynamic-linker=/system/bin/linker For FPC: -k--dynamic-linker=/system/bin/linker Did this and it started working, got "Hello bucket" printed lolHmm... I thought Android (from its Android subsystem) can't run pure elf binaries. Nice info *thumbs up emoticon*