Recent

Author Topic: Problems with android crosscompiling Linux  (Read 4650 times)

Imants

  • Full Member
  • ***
  • Posts: 196
Problems with android crosscompiling Linux
« on: February 11, 2016, 09:30:36 am »
I build ppcrosarm compiler in my Linux server using this comand:
sudo make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=/home/dhc-user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin OPT=-dFPC_ARMEL INSTALL_PREFIX=/usr

And I have problem. When I tired to build androidlcltest project using os "Android" all compiled but my program instantly crashed
lazbuild --compiler=/usr/lib/fpc/3.0.0/ppcrossarm --ws=customdrawn --os=android --cpu=arm --build-all androidlcltest.lpi

THen I read that I need to use "Linux" as os, but when I tired to compile using os "Linux":
lazbuild --compiler=/usr/lib/fpc/3.0.0/ppcrossarm --ws=customdrawn --os=linux --cpu=arm --build-all androidlcltest.lpi

I got compilation error
"Assembler messages:
Fatal error: invalid -march= option: `armv6'"

Maybe someone have encountered this problem.

Library values are these:
<Libraries Value="/home/dhc-user/android-ndk-r10e/platforms/android-14/arch-arm/usr/lib/;/home/dhc-user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/"/>

and my path variable contains:
/usr/local/games:/home/dhc-user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/


Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Problems with android crosscompiling Linux
« Reply #1 on: February 11, 2016, 10:06:17 am »
Run adb logcat then run your app, when it crashes, stop logcat and analyze the log. That's how you debug an android app for now, until remote debugging is fully implemented. Don't use linux as os target, android has been a separate target since it's fully supported in the compiler. Also make sure you're using the correct arm architecture define for your phone if needed (I forgot what's the value if not specified, but it's working on my Xiaomi phone), plus the correct -Cf (just in case your SoC doesn't have proper floating point hardware, -CfSOFT might solve the problem since it's software emulation which should work on any SoC).

Imants

  • Full Member
  • ***
  • Posts: 196
Re: Problems with android crosscompiling Linux
« Reply #2 on: February 11, 2016, 11:48:59 am »
I changed -CpARMV6 to -CpARMV7 and now I got strange errors:

(9009) Assembling secondform
/home/dhc-user/control/projects/androidlcl/lib/arm-android/secondform.s: Assembler messages:
/home/dhc-user/control/projects/androidlcl/lib/arm-android/secondform.s:10: Error: lo register required -- `stmfd r13!,{r11,r12,r14,r15}'
/home/dhc-user/control/projects/androidlcl/lib/arm-android/secondform.s:11: Error: lo register required -- `sub r11,r12,#4'

Lazarus source mikropiles without problems. 

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Problems with android crosscompiling Linux
« Reply #3 on: February 11, 2016, 01:18:00 pm »
I changed -CpARMV6 to -CpARMV7 and now I got strange errors:

(9009) Assembling secondform
/home/dhc-user/control/projects/androidlcl/lib/arm-android/secondform.s: Assembler messages:
/home/dhc-user/control/projects/androidlcl/lib/arm-android/secondform.s:10: Error: lo register required -- `stmfd r13!,{r11,r12,r14,r15}'
/home/dhc-user/control/projects/androidlcl/lib/arm-android/secondform.s:11: Error: lo register required -- `sub r11,r12,#4'

Lazarus source mikropiles without problems.
Two possibilities: your binutils (as to be exact) doesn't support such construct or it's a but in the arm-android code generator. However, since it's working fine in my computer, it looks like the binutils. What NDK version and what GCC/Clang version do you use?

Imants

  • Full Member
  • ***
  • Posts: 196
Re: Problems with android crosscompiling Linux
« Reply #4 on: February 11, 2016, 01:28:47 pm »
I compiled OpenGL test project witch is located here
https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/android-ndk/examples/opengltest/
It compiled and worked on my phone. So I will try to check diferences between those two

Imants

  • Full Member
  • ***
  • Posts: 196
Re: Problems with android crosscompiling Linux
« Reply #5 on: February 11, 2016, 01:30:28 pm »
My NDK:

/home/dhc-user/android-ndk-r10e/platforms/android-14/arch-arm/usr/lib/

I know I installed GCC/Clang but I do not know how to get witch version :(

Imants

  • Full Member
  • ***
  • Posts: 196
Re: Problems with android crosscompiling Linux
« Reply #6 on: February 11, 2016, 03:37:05 pm »
I tried to use logcat to see why LCL test application do not work

I used adb logcat -s AppMonitor and got:

D/AppMonitor( 2680): State of com.pascal.lcltest.LCLActivity changed to LAUNCHED at 75981465236
D/AppMonitor( 2680): State of com.andyroid.launcher.Launcher changed to BACKGROUND at 75981465236
D/AppMonitor( 2680): State of com.pascal.lcltest.LCLActivity changed to TERMINATE at 93579422053
D/AppMonitor( 2680): State of com.andyroid.launcher.Launcher changed to FOREGROUND at 93579422053

Nothing useful I think.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Problems with android crosscompiling Linux
« Reply #7 on: February 11, 2016, 05:10:55 pm »
I tried to use logcat to see why LCL test application do not work

I used adb logcat -s AppMonitor and got:

D/AppMonitor( 2680): State of com.pascal.lcltest.LCLActivity changed to LAUNCHED at 75981465236
D/AppMonitor( 2680): State of com.andyroid.launcher.Launcher changed to BACKGROUND at 75981465236
D/AppMonitor( 2680): State of com.pascal.lcltest.LCLActivity changed to TERMINATE at 93579422053
D/AppMonitor( 2680): State of com.andyroid.launcher.Launcher changed to FOREGROUND at 93579422053

Nothing useful I think.
Not enough, upon crash you should get something like:
Code: Bash  [Select][+][-]
  1. I/ActivityManager(  274): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.pascal.lcltest/.LCLActivity} from pid 393
  2. D/PermissionCache(   36): checking android.permission.READ_FRAME_BUFFER for uid=1000 => granted (1213 us)
  3. D/dalvikvm(  744): Not late-enabling CheckJNI (already on)
  4. I/ActivityManager(  274): Start proc com.pascal.lcltest for activity com.pascal.lcltest/.LCLActivity: pid=744 uid=10041 gids={50041, 1015, 1028}
  5. E/SurfaceFlinger(   36): ro.sf.lcd_density must be defined as a build property
  6. E/Trace   (  744): error opening trace file: No such file or directory (2)
  7. I/lclapp  (  744): Trying to load liblclapp.so
  8. D/dalvikvm(  744): Trying to load lib /data/app-lib/com.pascal.lcltest-1/libjavanesechess.so 0x40ce6528
  9. D/dalvikvm(  744): Added shared lib /data/app-lib/com.pascal.lcltest-1/libjavanesechess.so 0x40ce6528
  10. I/lclapp  (  744): JNI_OnLoad called
  11. I/lclapp  (  744): Reading our Activity Class
  12. I/lclapp  (  744): JNI_OnLoad finished
  13. I/lclapp  (  744): LCLOnCreate called by LCLActivity.onCreate
  14. I/lclapp  (  744): [TCDWSCustomForm.ShowHide] First form layout adjustment lOldDPI=96 lNewDPI=240 lOldFormWidth=100 lNewFormWidth=100
  15. E/SurfaceFlinger(   36): ro.sf.lcd_density must be defined as a build property
  16. D/libEGL  (  744): loaded /system/lib/egl/libEGL_emulation.so
  17. D/        (  744): HostConnection::get() New Host Connection established 0x2a185828, tid 744
  18. D/libEGL  (  744): loaded /system/lib/egl/libGLESv1_CM_emulation.so
  19. D/libEGL  (  744): loaded /system/lib/egl/libGLESv2_emulation.so
  20. W/EGL_emulation(  744): eglSurfaceAttrib not implemented
  21. D/OpenGLRenderer(  744): Enabling debug mode 0
  22. I/lclapp  (  744): onCreateOptionsMenu
  23. I/lclapp  (  744): onPrepareOptionsMenu
  24. I/lclapp  (  744): LCLOnMenuAction called kind=0 itemIndex=0
  25. E/dalvikvm(  744): JNI ERROR (app bug): accessed stale local reference 0x59400031 (index 12 in a table of size 9)
  26. W/dalvikvm(  744): JNI WARNING: jclass is an invalid local reference (0x59400031)
  27. W/dalvikvm(  744):              in Lcom/pascal/lcltest/LCLActivity;.LCLOnMenuAction:(II)I (NewObjectArray)
  28. I/dalvikvm(  744): "main" prio=5 tid=1 RUNNABLE
  29. I/dalvikvm(  744):   | group="main" sCount=0 dsCount=0 obj=0x40a729a0 self=0x2a00bba8
  30. I/dalvikvm(  744):   | sysTid=744 nice=0 sched=0/0 cgrp=apps handle=1073849308
  31. I/dalvikvm(  744):   | state=R schedstat=( 501565227 526311613 147 ) utm=30 stm=20 core=0
  32. I/dalvikvm(  744):   at com.pascal.lcltest.LCLActivity.LCLOnMenuAction(Native Method)
  33. I/dalvikvm(  744):   at com.pascal.lcltest.LCLActivity.onPrepareOptionsMenu(LCLActivity.java:285)
  34. I/dalvikvm(  744):   at android.app.Activity.onPreparePanel(Activity.java:2508)
  35. I/dalvikvm(  744):   at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:435)
  36. I/dalvikvm(  744):   at com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:769)
  37. I/dalvikvm(  744):   at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:201)
  38. I/dalvikvm(  744):   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
  39. I/dalvikvm(  744):   at android.view.Choreographer.doCallbacks(Choreographer.java:562)
  40. I/dalvikvm(  744):   at android.view.Choreographer.doFrame(Choreographer.java:531)
  41. I/dalvikvm(  744):   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
  42. I/dalvikvm(  744):   at android.os.Handler.handleCallback(Handler.java:725)
  43. I/dalvikvm(  744):   at android.os.Handler.dispatchMessage(Handler.java:92)
  44. I/dalvikvm(  744):   at android.os.Looper.loop(Looper.java:137)
  45. I/dalvikvm(  744):   at android.app.ActivityThread.main(ActivityThread.java:5041)
  46. I/dalvikvm(  744):   at java.lang.reflect.Method.invokeNative(Native Method)
  47. I/dalvikvm(  744):   at java.lang.reflect.Method.invoke(Method.java:511)
  48. I/dalvikvm(  744):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  49. I/dalvikvm(  744):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  50. I/dalvikvm(  744):   at dalvik.system.NativeStart.main(Native Method)
  51. I/dalvikvm(  744):
  52. E/dalvikvm(  744): VM aborting
  53. ...
  54. D/Zygote  (   37): Process 744 terminated by signal (11)
  55. I/ActivityManager(  274): Process com.pascal.lcltest (pid 744) has died.
  56. I/WindowState(  274): WIN DEATH: Window{410a7358 u0 com.pascal.lcltest/com.pascal.lcltest.LCLActivity}
  57. W/ActivityManager(  274): Force removing ActivityRecord{40f88938 u0 com.pascal.lcltest/.LCLActivity}: app died, no saved state
  58.  

 

TinyPortal © 2005-2018