Building Compiler for Win7 (32bit,64bit) lazarus / 43-Android ---------------------------------------------------------------------- simonsayz · 2013-12-21 13:45 Hello, This is simple tutorial for Building Compiler for Win7 (32bit, 64bit) It works ArmV6, ArmV7, X86 with native code Tested   Nexus7, Nexus7 2013, Iconiatab w500   Virtual machine ( ex. BlueStacks, Android on VMWare ) Ref. http://blog.naver.com/simonsayz/120204060881 QuoteSpecial Thanks to      Lens, engkin in Lazarus Forms       http://forum.lazarus.freepascal.org/index.php/topic,22944.0.html Best Regards Simon,Choi ---------------------------------------------------------------------- Sergionn · 2013-12-22 07:55 Simon, thanks for you work! But what about your components: do you have you any plans to support And_GLESv2_Canvas.pas in lazarus and delphi xe5 for win? and will be the new versions of and_controls? ---------------------------------------------------------------------- simonsayz · 2013-12-22 15:34 @Sergionn I do two projects in this year.  Quote- with free Pascal compiler      multi platform image library for commercial cloud service.        / windows, ios, android, redhat 32,64bit - with Delphi 7,XE5      photo album editor on openGL based As the result, I have the bunch of code related openGl. so, publish the code except commerical project in near future.  ( 1/4 2014 ) but In this time, I do migrate the code written by jmpessoa first. Best Regards Simon,Choi ---------------------------------------------------------------------- lenz · 2013-12-29 16:56 @simonsayz: Have you been able to run ARMv6 binary on actual Android device that has ARMv6? I'm asking because in my case, the application just hangs on ARMv6 device (with Gingerbread), there is no SIGSEGV, nothing. Library entry points are apparently not called, so it's just sits there and then OS asks to close application that is not responding. I even tried compiling for ARMv5 and SOFT fpu, but same result. I'm wondering if it is my device or an issue with library. Edit: Never mind, I could finally run my binary on ARMv6 device, rare  Samsung GT-B7510. My application was hanging because I was loading dynamic libraries, EGL and GLES, in unit initialization section, which was blocking forever (due to bug documented here) - had to move that code to "startup" section of AppGlue. ---------------------------------------------------------------------- hinst · 2014-01-04 15:55 I did everything exactly as the article explains; but I can't get it to work. When I try to compile my project from Lazarus I get the following compiler messages: Code: [Select]PPU Loading D:\Lazarus\fpc\2.7.1\units\arm- android\rtl\system.ppu PPU Loading D:\Lazarus\fpc\2.6.2\units\arm-android\rtl\system.ppu fcllaz.pas(0,0) Fatal: Can not find system used by fcllaz, ppu=..\..\fpc\2.6.2\units\arm-android\rtl\system.ppuHelp me pls if U can The funny thing is that file D:\Lazarus\fpc\2.6.2\units\arm- android\rtl\system.ppu is present on my PC, however it looks like compiler either can't find it or just does not like it. Which is strange because I did everything as the article suggests; I also find it strange that compiler searches for system unit in two locations; first in 2.7.1 subfolder, then in 2.6.2 subfolder; (I copied units folder from 2.7.1 to 2.6.2 as suggested) Help plz I could get android FPC compiler to work once; it worked for me when I used CodeTyphon; this time I can't use CodeTyphon ---------------------------------------------------------------------- Leledumbo · 2014-01-05 00:48 QuoteThe funny thing is that file D:\Lazarus\fpc\2.6.2\units\arm- android\rtl\system.ppu is present on my PC, however it looks like compiler either can't find it or just does not like it. Which is strange because I did everything as the article suggests; I also find it strange that compiler searches for system unit in two locations; first in 2.7.1 subfolder, then in 2.6.2 subfolder; (I copied units folder from 2.7.1 to 2.6.2 as suggested)Either fpc.cfg or the project settings must have path for both versions, which shouldn't happen and of course could confuse the compiler because it finds 2 different version of the unit, thus attempting to look for the original source code for recompilation to generate the correct version, but it can't find one, so the compilation is aborted with that message. If you copy the hidden messages as well, you might see "PPU checksum changed" message which is the indicator that the compiler sees the wrong unit. ---------------------------------------------------------------------- hinst · 2014-01-05 11:33 thanks for the tip; I still can't get it to work. I removed fpc\2.7.1 directory from where it was; now I get the following compiler messages: Code: [Select]Hint: Start of reading config file D:\Lazarus\fpc\2.6.2\bin\x86_64-win64\fpc.cfg Hint: End of reading config file D:\Lazarus\fpc\2.6.2\bin\x86_64-win64\fpc.cfg Free Pascal Compiler version 2.7.1 [2014/01/04] for arm Copyright (c) 1993-2013 by Florian Klaempfl and others Target OS: Android for ARMEL Compiling fcllaz.pas PPU Loading D:\Lazarus\fpc\2.6.2\units\arm-android\rtl\system.ppu Trying to use a unit which was compiled with a different FPU mode fcllaz.pas(0,0) Fatal: Can not find system used by fcllaz, ppu=..\..\fpc\2.6.2\units\arm-android\rtl\system.ppu This time I clicked "Copy both visible and hidden messages" in Lazarus. I have no idea what to do --- --- --- Looks like I identified the problem; it says "unit was compiled with a different FPU mode". However I still can't get it to work; this is what I tried: set -CfVFPv2 compiler option (I actually built fpc for android with this option earlier), then I also tried -CfVFPv3 and -CfVFPv1. None made it work; it still says "compiled with a different FPU mode". Help plz!!! ---------------------------------------------------------------------- Leledumbo · 2014-01-05 11:52 QuoteLooks like I identified the problem; it says "unit was compiled with a different FPU mode". However I still can't get it to work; this is what I tried: set -CfVFPv2 compiler option (I actually built fpc for android with this option earlier), then I also tried -CfVFPv3 and -CfVFPv1. None made it work; it still says "compiled with a different FPU mode". Help plz!!!How do you build the compiler set (compiler + rtl + other packages) then? Of course they must match. If you build the compiler set with -CfVFPv2, you must pass the same option when building your projects. One more thing, what version are you building? 2.6.2 or 2.7.1? I don't think 2.6.2 supports arm-android so you must use 2.7.1. DON'T copy compiled units for 2.7.1 to 2.6.2 directory, let them be separated. fpc.cfg should resolve the correct directory based on $fpcversion macro. You better post your fpc.cfg and let's fix that. ---------------------------------------------------------------------- hinst · 2014-01-06 09:27 QuoteHow do you build the compiler set (compiler + rtl + other packages) then?I have two compiler instances: FPC 2.6.2 which comes prebuilt with Lazarus release for Windows. I also downloaded FPC 2.7.1 trunk sources from subversion repository. Then I built FPC 2.7.1 for Android using FPC 2.6.2 for Windows. So my second compiler is built by the first one. Quote...they must match. If you build the compiler set with -CfVFPv2, you must pass the same option when building your projects.So I wonder why setting this option didn't make it work..... QuoteI don't think 2.6.2 supports arm-android so you must use 2.7.1.Yes, exactly; this is why I built FPC 2.7.1 from subversion trunk Quotefpc.cfg should resolve the correct directory based on $fpcversion macro. You better post your fpc.cfg and let's fix that.After I built FPC 2.7.1 only one file was generated in the bin directory: ppcrossarm.exe; but fpc.cfg file was not generated. This is why I relied on the old fpc.cfg file from FPC 2.6.2 and copied ppcrossarm.exe file to bin directory of the existing FPC 2.6.2 compiler instance as the article suggests So... any idea? plz. I really have to make this work; I am working on a project for my coursework. I already developed a considerable part of the application before I had to switch from CodeTyphon to Lazarus; so if I won't be able to configure the compiler for my project, the consequences will be pretty bad for me; sorry to lay my problems on you, I just wanted to let you know that I'm currently researching the issue not just to satisfy my curiosity ---------------------------------------------------------------------- lenz · 2014-01-06 19:23 You can try some of my scripts. The following files are located in my "d:\FreePascal" folder, while FPC source from the trunk is located in "d:\FreePascal\Source". Also they need latest Android NDK. You may need to adjust paths. Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i rem Specify here the folder in which you have existing FPC 2.6.2 installation.set FPC_PATH=d:\FreePascal\2.6.2\bin\i386-win32set PPCBIN=%FPC_PATH%\fpc.exe rem This should point to your existing Android NDK.set NDK_BIN=c:\Android\android-ndk-r9c\toolchains\arm- linux-androideabi-4.8\prebuilt\windows-x86_64\bin\ rem This is where resulting files will be generated.set INSTALL_PATH=d:\FreePascal\ARMv6 set PATH=%FPC_PATH%;%NDK_BIN%;%PATH%cd Source%FPC_PATH%\make clean crossall crossinstall FPC=%PPCBIN% OS_TARGET=android CPU_TARGET=arm CROSSOPT="-CpARMv6 -CfVFPV2 -OoFASTMATH" INSTALL_PREFIX=%INSTALL_PATH%cd ..copy fpc_ARMv6.cfg %INSTALL_PATH%\bin\i386-win32\fpc.cfg  Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -Fud:\FreePascal\ARMv6\units\$FPCTARGET\* #ifdef android#ifdef cpuarm- Flc:\Android\android-ndk-r9c\platforms\android-19\arch- arm\usr\lib\#endif#endif  Then, I compile my project file with this batch (it should be placed in Eclipse's project folder within "jni" sub-folder). Adjust paths accordingly. Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i set PREFIX=arm-linux-androideabi-set NDK_BIN=c:\Android\android- ndk-r9c\toolchains\arm-linux- androideabi-4.8\prebuilt\windows-x86_64\binset NDK_LIB=c:\Android\android-ndk-r9c\platforms\android-19\arch- arm\usr\libset PLATFORM=-Tandroid -CpARMv6 -CfVFPV2 -OoFASTMATH -Mdelphiset LIBOUTPUT=..\libs\armeabiset UNITS=-FU"TempARMv6" -Fl%LIBOUTPUT% -FL%NDK_LIB%\libdl.soset LINKING=-Xd -XP%PREFIX% -FD%NDK_BIN% -Fu%NDK_LIB%set CODEGEN=-O3 -CX -XX -Xs -dPXL_ARMv6IF not exist TempARMv6 mkdir TempARMv6d:\FreePascal\ARMv6\bin\i386-win32\ppcrossarm.exe %PLATFORM% %UNITS% %LINKING% %CODEGEN% -o%LIBOUTPUT%\libtest.so test.lpr  I'm using Lazarus for editing and I have it configured to compile ARMv7 and x86, but since you cannot combine units for ARMv6 and ARMv7 targets (since both use same name), I use scripts for "release" build. Let me know if you want to see my ARMv7 and x86 scripts. Hope these help. P.S. If you need to rebuild cross-compiler and RTL, just delete the entire "ARMv6" folder and re-run scripts. "Clean" operation doesn't seem to remove everything so you may get messages of incompatible units. P.S.2. Do not try this with FPC trunk sources with revision 26398 or later as it will break due to this bug, use revision 26397 or earlier. ---------------------------------------------------------------------- Leledumbo · 2014-01-07 09:23 QuoteAfter I built FPC 2.7.1 only one file was generated in the bin directory: ppcrossarm.exe; but fpc.cfg file was not generatedIt is not. There will be one and only one fpc.cfg that will be used by the compiler by default, and it's shared with ALL (cross) compilers. I suspect your fpc.cfg is somewhat incorrect to be used for cross building environment, that's why I ask you to post it. It's OK to copy the cross compiler to 2.6.2 bin directory as in windows, it's a bit difficult to make 2.6.2 binaries coexist with 2.7.1 ones because the lack of symlinks, but other than that (units, etc.) should live on its own 2.7.1 directory. Again, this is defined in your fpc.cfg. ---------------------------------------------------------------------- hinst · 2014-01-07 09:39 I tried it once again using your @lenz scripts, it didn't work once again... I got the very same error: different FPU mode. Then I moved these options: -OoFASTMATH -CfVFPv2 -CpARMv6 from Lazarus project settings to fpc.cfg file and this error suddenly disappeared. I still have no idea why it didn't work when these options were specified in Lazarus project settings. Thanks, now I can build my project. Actually, it turned out that I was not careful when creating a back up copy of my project, and now some units are missing because they were placed in a different folder. I just realized that I decided to place units common to android platform (AndroidLog, AndroidKeycodes) to a separate folder; but later I forgot about it; so now these units are completely gone. I hope rewriting them won't take too much time. Good thing I got a backup copy of the game engine I was using. Otherwise it would be a complete disaster because I had to make several far from obvious changes to it before it started to work on Android properly. People be careful when creating backups; check for additional units you might use plz  Thanks to everyone who helped me to resolve the issue once again. P.S.: @lenz about that bug: it says "fixed" on the page, so I decided to try the latest revision once again, and it worked; so I guess you can use the latest revision from now on as well