Recent

Author Topic: about android 5.0  (Read 7291 times)

gtyhn

  • New member
  • *
  • Posts: 5
about android 5.0
« on: November 28, 2015, 06:29:47 am »
Create a new empty program, and then write the following code:

Code: Pascal  [Select]
  1. program project1;
  2.  
  3. uses
  4.   Classes;
  5.  
  6. begin
  7.   Writeln('hello world');
  8. end.    
  9.  

Push to run android 5.0 system:

error: only position independent executables (PIE) are supported.

can you tell me how to solve?

android.mk:

LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE

lazuars how?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1476
Re: about android 5.0
« Reply #1 on: November 29, 2015, 02:40:49 pm »
Hello gtyhn!

The way to you get an android apk may be somewhat longer....

You need a Lazarus prepared to cross-compile..

for windows there is: Laz4Android:

FPC: 3.0.0 "Pestering Peacock" (win32/arm-android/i386-android/jvm-android)
Lazarus:1.4.4
Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)
ref. http://sourceforge.net/projects/laz4android/files/?source=navbar

And then you can install the Lamw/Lazarus Android Module Wizard
to get a "Form Designer and Components development model!"

ref1. https://github.com/jmpessoa/lazandroidmodulewizard      

ref2.http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html


« Last Edit: November 29, 2015, 03:30:56 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: about android 5.0
« Reply #2 on: November 30, 2015, 03:20:42 am »
It seems that FPC is capable of producing position independent code, according to this:
Quote
A position-independent executable is simply an executable that only
contains position-independent code and that is linked with the "-pie"
linker option. So compiling all code with -Cg (the standard FPC RTL and
packages are compiled like that by default on Linux/x86-64) and then
linking your application with the -kpie command line option should be
enough.

I would be interested to know if you (or anyone else) succeed (or fail) in running an executable file produced using this method. I assume it works under Terminal Emulator if it has the right mode (755?) and NOT located on the SD card.

gtyhn

  • New member
  • *
  • Posts: 5
Re: about android 5.0
« Reply #3 on: November 30, 2015, 04:56:18 am »
Thanks for jmpessoa and engkin reply!

I have configured cross-compiling, i use CodeTyphon. but I don't know how to join in the lazarus "-pie" compiler options.

Android 5.0 native code must be enabled PIE.

If using c/c + +. I know the android.mk add:

LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE

So I need to know if on lazarus, support open "-PIE" option to compile?

gtyhn

  • New member
  • *
  • Posts: 5
Re: about android 5.0
« Reply #4 on: November 30, 2015, 05:51:53 am »
I use "-kpie" compiler options, the following error:

c:\codetyphon\fpc\fpc32\bin\i386-win32\arm-android-ld.exe: cannot find pie: No such file or directory

Leledumbo

  • Hero Member
  • *****
  • Posts: 8114
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: about android 5.0
« Reply #5 on: November 30, 2015, 10:49:34 am »
I use "-kpie" compiler options, the following error:

c:\codetyphon\fpc\fpc32\bin\i386-win32\arm-android-ld.exe: cannot find pie: No such file or directory
if you want to pass option to linker, don't forget the leading dash. i.e.: it should be -k-pie, assuming ld expects -pie

gtyhn

  • New member
  • *
  • Posts: 5
Re: about android 5.0
« Reply #6 on: December 01, 2015, 09:58:03 am »
Thank you Leledumbo.

Use "-k-pie" successful compilation, and can be run on android 5.0 success!

Thanks for everyone help and reply!

jmpessoa

  • Hero Member
  • *****
  • Posts: 1476
Re: about android 5.0
« Reply #7 on: December 01, 2015, 05:23:29 pm »

Hello gtyhn,

Congratulations!

What about a "tutorial"?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

gtyhn

  • New member
  • *
  • Posts: 5
Re: about android 5.0
« Reply #8 on: December 02, 2015, 03:59:33 am »
This is very simple, only need to configure the android cross-compilation environment well, and then in the project Options "Compiler Options" - > "Compilation and Linking" - > "Linking" - > "Pass Options to would with - k, delimiter isspace" add "-pie"

jmpessoa

  • Hero Member
  • *****
  • Posts: 1476
Re: about android 5.0
« Reply #9 on: December 29, 2015, 08:54:36 pm »

Hello gtyhn!

"Lamw" now can produce a "executable"....

But, how to run/install it?

I try "adb push" to my device [not rooted]  "/data/tmp"  but I got "permission denied" .... 

I will need a "terminal emulator"?... some suggestion?

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7587
Re: about android 5.0
« Reply #10 on: December 29, 2015, 09:05:43 pm »
LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE


Those look like GCC parameters. Try to substitute with FPC commandline parameters like -Cg

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: about android 5.0
« Reply #11 on: December 29, 2015, 09:51:37 pm »
I try "adb push" to my device [not rooted]  "/data/tmp"  but I got "permission denied" .... 

The steps are:
1-Copy it to a folder that the OS allows running an executable from within.
   ... The folder I used is  /data/local/tmp
   ... I don't think you can put anything there without root!
2-Change the mode of the file to 755 to allow everyone to run it.
3-Use adb or Terminal Emulator to run it.
   ... If you are comfortable with adb commands then you don't need Terminal Emulator.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1476
Re: about android 5.0
« Reply #12 on: December 29, 2015, 10:11:59 pm »


Quote
... I don't think you can put anything there without root!

 :(  :'(

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 1476
Re: about android 5.0
« Reply #13 on: December 29, 2015, 11:45:17 pm »
Hello engkin!

Yes, now I was able to to confirm [Attachment picture from emulator] !

Lamw now does android console/executable app!

I will update github!

Thank you and All!

P.S. [Edited] here another good ref: http://kevinboone.net/android_native.html
« Last Edit: December 30, 2015, 12:17:13 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: about android 5.0
« Reply #14 on: December 30, 2015, 01:01:47 am »
Hello engkin!

Yes, now I was able to to confirm [Attachment picture from emulator] !

Lamw now does android console/executable app!

I will update github!

Thank you and All!

P.S. [Edited] here another good ref: http://kevinboone.net/android_native.html

Good job!

Thanks for the link. A Windows person like me needs a lot of these articles.