Recent

Author Topic: [Tutorial] Cross Compile for arm-linux (Finally it works!)  (Read 178579 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #30 on: January 13, 2010, 02:42:31 pm »
Marc IS THE BEST, FOREVER.

Quote
what do those () there ?

That was the problem, Lazarus have crosscompile the LCL without problems.

Now i have tried to compile the program with ARM cpu and linux OS and ...

Quote
Linking /home/fred/firstprog/miximum
/home/fred/lazarus9.29/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/home/fred/lazarus9.29/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.a when searching for -lX11
/home/fred/lazarus9.29/fpc/binutils/ld: cannot find -lX11
miximum.lpr(33) Error: Error while linking
miximum.lpr(33) Fatal: There were 1 errors compiling module, stopping
TMessagesView.CollectLineParts WARNING: 26<>22 SrcLine=miximum.lpr(33) Fatal: There were 1 errors compiling module, stopping

Those errors issue because the target libs are missing, that not the fault of Lazarus.

Next step : i have to win a Nokia or a other smartphone to really test my application.

Step by step, that jungle become a nice garden.

Thanks Marc  :P
« Last Edit: January 13, 2010, 02:52:13 pm by fredvs »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

danzman

  • Newbie
  • Posts: 6
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #31 on: January 13, 2010, 03:04:38 pm »
I have been following the exchanges with Fred and the gurus and I think Fred arrived at a point where HE can write the tutorial on how to recompile lazarus/fpc to cross-compile for use with ARM (nokia N900) based machines. My set-up is similar with Fred's. How about it Fred?

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #32 on: January 13, 2010, 03:15:22 pm »
Hi Danzman, i have sent you a mail.
This night i gonna write a tuto for dummies like me.
Many thanks to Kjooow and SuperMarc.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #33 on: January 13, 2010, 08:33:12 pm »
Hello folks.
Here some infos for installing cross-arm-compiler on a working fpc-lazarus system.
Many-many thanks to Kjooob who have done all the work  :P

1. Install FPC and Lazarus sources and SVN

Here is the best link i have find to install it (explanations are in French, just follow the command or use a translator)

http://lazarus-fr.espace-malin.fr/index.php?option=com_content&view=article&id=44:installer-lazarus-et-freepascal-svn-sous-ubuntu&catid=2:installation-de-lazarus&Itemid=4

In this tuto i have installed the sources folder in /home/user/lazarus
(!!!! Replace user by your user name in all the command following !!!!).

2. Install & Configure Binutils

1) Download binutils-2.20.tar.gz from http://ftp.gnu.org/gnu/binutils/binutils-2.20.tar.gz

2) Extract binutils-2.20.tar.gz in:
   home/user/fpc_tools/binutils-2.20

3) From console : cd /fpc_tools/binutils-2.20

4) From console : ./configure --target=arm-linux --disable-werror

5) From console : make

6) From console : sudo make install

7) From console :
   mkdir home/user/lazarus/fpc/binutils
   ln -s /usr/local/bin/arm-linux-ar home/user/lazarus/fpc/binutils/ar
   ln -s /usr/local/bin/arm-linux-ld home/user/lazarus/fpc/binutils/ld
   sudo mv /usr/local/bin/arm-linux-as /usr/local/bin/arm-linux-as_org


8 ) From console :
sudo gedit /usr/local/bin/arm-linux-as

   paste:

#!/bin/sh
/usr/local/bin/arm-linux-as_org -meabi=5 $@

9) save and close gedit

10) From console : sudo chmod +x /usr/local/bin/arm-linux-as

11) From console : ln -s /usr/local/bin/arm-linux-as home/user/lazarus/fpc/binutils/as


3. Configure FPC for ARM:

1) From console : cd /lazarus/fpc/2.5.1/

2) From console : sudo make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=/home/user/lazarus/fpc/binutils/ OPT=-dFPC_ARMEL INSTALL_PREFIX=/usr
  
3) From console : sudo gedit /etc/fpc.cfg

4) Paste at end:

#DEFINE LAZARUS

-Fu/usr/lib/fpc/2.5.1/units/$fpctarget/*
-Fl/usr/lib/fpc/2.5.1/units/$fpctarget/rtl/

-a
-Sd
-Xd
-Xs

-O-

#IFDEF CPUARM
-XP/home/kjow/lazarus/fpc/binutils/
-Xr/usr/lib/fpc/2.5.1/units/arm-linux/rtl/
-Xr/home/kjow/lazarus/fpc/libcross
-XR/home/kjow/lazarus/fpc/
-darm
-Tlinux
#ENDIF

5) save and close gedit

6) From console : sudo ln -sf /usr/lib/fpc/2.5.1/ppcrossarm /usr/local/bin/ppcarm

4. Cross compile the LCL:
 
From console : sudo startlazarus
  From the IDE:
    * Open Tools / Configure Build Lazarus / Advanced Build Options.
    * In Target OS write linux and in Target CPU write arm.
    * Set LCL and Package registration to Build (the middle radio button) and all other to None (left radio buttons).
    * Click the Build button.

5. Set Targets:

  From the IDE:
    * Set in Project / Compiler Options / Code / Target OS (-T): Linux
    * Set in Project / Compiler Options / Code / Target CPU family (-P): arm

That all folks  ::)
« Last Edit: January 14, 2010, 03:14:14 pm by fredvs »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

danzman

  • Newbie
  • Posts: 6
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #34 on: January 14, 2010, 06:06:54 am »
Hey Fred, many thanks for the nice tutorial. I will be down into my dungeon, where my linux machine is, and give your instructions a good try out. I am sure I will be asking for more questions but in the meantime I will do it on my own. But... watch out for my cry for help  8)

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #35 on: January 14, 2010, 03:12:34 pm »
Hi Danzman.
Hope it helps you because i take the ship to Afrika tomorrow and will be offline for 3 months....
Cheers
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

kattle87

  • Newbie
  • Posts: 3
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #36 on: March 01, 2010, 11:51:32 pm »
Hi guys.
I followed the main tutorial and got a successful cross-compile of the "TestARM.pas" file. when I do "file TestARM" the answer is: TestARM: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped.
I must say I've not imported the libs for crosscompilation but I got no errors anyway.
When I try to run the program on my N900 it will say "sh: ./TestARM: Permission denied". No matter if I chmod the file, or try running as superuser.
Suggestions anyone?

EDIT: I compiled it with:
fpc -Tlinux -Parm
« Last Edit: March 01, 2010, 11:55:19 pm by kattle87 »

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #37 on: March 02, 2010, 09:58:39 am »
What does "ldd ./TestARM" report?
Lazarus 1.7 (SVN) FPC 3.0.0

kattle87

  • Newbie
  • Posts: 3
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #38 on: March 02, 2010, 11:20:55 am »
ldd TestARM reports:
Code: [Select]
ldd: warning: you do not have execution permissions for './TestARM'
          not a dynamic executable

The funny thing is that I tried running the executable with qemu-arm (user mode emulation) on my PC and it just works... (With the correct output! That is this is an ARM executable)

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #39 on: March 02, 2010, 12:48:14 pm »
There are many different variations of ARM platform. As far as I know, the N900 works with ARM v5 and you have to build the cross compiler for that type of ARM. Read the tutorial again, maybe you will find hints on that issue.
Lazarus 1.7 (SVN) FPC 3.0.0

kattle87

  • Newbie
  • Posts: 3
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #40 on: March 03, 2010, 11:11:13 am »
I checked the tutorial again but I think I made everything right. Could someone of you guys that successfully cross-compiled somethingfor the N900 post it in here, so that I can check whether it's a problem of mine or not? (EG: the OP surely succeded in this)

typo

  • Hero Member
  • *****
  • Posts: 3051

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #42 on: March 18, 2010, 10:11:57 am »
If I compare this thread with the recent Sheeva thread (http://lazarus.freepascal.org/index.php/topic,8057.0.html), I notice a couple of things:

- I didn't need the meabi=5 hack, but I did use -dFPC_ARMEL -CfSOFT -Cparmv5

IIRC I also added one or two other defines to the binutils generation (one to disable libintl, and one to make it forget internal directories) I'll look this up later.

I assume the latter is the same as the eabi hack. It might be that -CfSOFT is not needed per se (the Linux kernel might emulate VFP?), but in that case softfloat probably increases performance.


I agree with Ocye that the key is getting above table what particular ARM you are targeting.

Kjooow

  • Jr. Member
  • **
  • Posts: 90
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #43 on: March 18, 2010, 03:41:24 pm »
Hi all,
I just made some adjustment to the tutorial, I'm sorry if it not perfectly clear... I'm trying to make it more friendly as possible :)
Thanks to nstrikos for the hints ;)

Remember that the WIKI is the only authritative tutorial!
« Last Edit: March 18, 2010, 03:43:06 pm by Kjooow »

Kjooow

  • Jr. Member
  • **
  • Posts: 90
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #44 on: March 23, 2010, 12:50:57 am »
I made two scripts that download svn sources and zip needed to build and configure your Ubuntu (x86) box with Lazarus AND FPC (both are enabled to compile for i386-linux and cross compile for arm-linux).

See first post of this thread and the WIKI page for more info.

:)

 

TinyPortal © 2005-2018