Lazarus

Installation => PDAs and Smartphones => Topic started by: Kjooow on December 03, 2009, 01:14:46 pm

Title: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on December 03, 2009, 01:14:46 pm
How To setup Lazarus/FPC for arm-linux cross compiling.

I decided to remove this post to link ONLY the authoritative/updated WiKi-tutorial.

Please follow these links:
Title: Re: Cross Compile for arm-linux
Post by: Ocye on December 03, 2009, 05:06:18 pm
It seems to me, ARM isn't the prefered target platform of most users. I didn't get any respond to my questions. Anyway, I would appreciate an updated tutorial. Maybe that helps growing the community.
Title: Re: Cross Compile for arm-linux
Post by: Kjooow on December 03, 2009, 06:17:41 pm
It seems to me, ARM isn't the prefered target platform of most users. I didn't get any respond to my questions. Anyway, I would appreciate an updated tutorial. Maybe that helps growing the community.

For this reason I would the help to create a tutorial "step-by-step", so users could create itself all necessary for development. There is a lot of unknowledge about this and tutorials are often outdated or cryptic.
Title: Re: [Tutorial] Cross Compile for arm-linux
Post by: Kjooow on December 10, 2009, 03:28:21 pm
First post updated.
Title: Re: [Tutorial] Cross Compile for arm-linux
Post by: Ocye on December 11, 2009, 11:59:49 am
Some notes from my experiences. First, I would suppose that fpc is installed, updated and used correctly. Omit the part until arm-linux from your tutorial. By the way, you say v2.2.4 and use 2.5.1. You just create Binutils and not Newlib. This have be done to have more function than "writeln" only. Actually, I appended some more options to configure binutils. Don't "cp" use "ln". I'm confused with your compiler name "ppcarm" instead of "ppcrossarm". I thought "cross" comes from the options crossinstall. You insert ARM options (i.e. -CfSOFT -CaEABI) into the fpc.cfg but add them to compilation too. Perhaps both are not needed since you created the compiler with them. AT least, a good tutorial should provide informations about the applied options. Why do you insert them, what happens, where are the files etc.

My procedure with binutils is as follows. I'm running Ubuntu where Synaptic or apt-get can be used to access repositories. How to create an ARM Toolchain is from the german wiki http://wiki.ubuntuusers.de/GNU_ARM-Toolchain

1. Synaptic -> binutils-source -> /usr/src/binutils -> binutils-2.19.1
download patch from http://sourceware.org/bugzilla/attachment.cgi?id=3058&action=view

2. Synaptic -> gcc-4.3-source -> /usr/src/gcc-4.3 -> gcc-4.3.3

3. Synaptic -> newlib-source -> /usr/src/newlib -> newlib-1.17.0

4. back to gcc (perhaps not necessary for freepascal)

After all it creates a structure in /opt/gnuarm which can be used to compile Hello-World. I was missing at least libgl and did not find a way to build it. So one can access different precompiled toolchains as well (http://www.gnuarm.com/, http://www.yagarto.de/, http://www.codesourcery.com/). I downloaded this file (http://www.codesourcery.com/downloads/public/gnu_toolchain/arm-none-linux-gnueabi/arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2) decompressed it to /opt (arm-2009q3) and applied that path to all further steps.

5. fpc

- crosszipinstall to create but not install
- -XR<> root dir where as and ld can be found
- ppcx64 is the compiler on 64bit systems, for 32bit it is called ppc386

It results in a packed file like fpc-2.5.1.arm-linux.tar.gz just where the makefile resides. Unpack the content to /usr/local/lib/fpc... and create a link for ppcrossarm into /usr/local/bin. Now ppcrossarm can be used to compile sources

6. Compilation

-Xd don't use standard lib path
-Fl use directory to search for libs
I don't know if it works without -C options.
Title: Re: [Tutorial] Cross Compile for arm-linux
Post by: Kjooow on December 11, 2009, 02:03:41 pm
Some notes from my experiences. First, I would suppose that fpc is installed, updated and used correctly. Omit the part until arm-linux from your tutorial. By the way, you say v2.2.4 and use 2.5.1. You just create Binutils and not Newlib. This have be done to have more function than "writeln" only. Actually, I appended some more options to configure binutils. Don't "cp" use "ln". I'm confused with your compiler name "ppcarm" instead of "ppcrossarm". I thought "cross" comes from the options crossinstall. You insert ARM options (i.e. -CfSOFT -CaEABI) into the fpc.cfg but add them to compilation too. Perhaps both are not needed since you created the compiler with them. AT least, a good tutorial should provide informations about the applied options. Why do you insert them, what happens, where are the files etc.

My procedure with binutils is as follows. I'm running Ubuntu where Synaptic or apt-get can be used to access repositories. How to create an ARM Toolchain is from the german wiki http://wiki.ubuntuusers.de/GNU_ARM-Toolchain

Hi, thanks for contribute.

My "tutorial" starts from a fresh linux (ubuntu 9.10 x86) installation, without any fpc/lazarus installed.

To compile daily snapshot of fpc (e.g. trunk revision 2.5.1) we need to install a precompiled version of fpc >= 2.2.4
For this reason first point of FPC section install it. On 2nd point of "Generic things" you can see that fpc source should be extracted on /home/user/lazarus/fpc/2.5.1/

So, now, you have an installed and working fpc_2.2.4 and sources of 2.5.1 version in a directory. In next steps we compile fpc_2.5.1 and we set it as default (replace 2.2.4). Now you have fpc_2.5.1 working on you machine.

After this, and Lazarus installation, I build latest binutils from their sources and I enable FPC to cross compile for arm.

What I miss now is Lazarus arm-linux compilation (such as arm-wince in lazarus)... I search for system units, but I don't understand where/how to give it to lazarus.

___

Why do you use "--target=arm-elf" instead of"--target=arm-linux"?

___

First post updated. Fixed some paths and some cp->ln
Title: Re: [Tutorial] Cross Compile for arm-linux
Post by: Ocye on December 11, 2009, 05:26:19 pm
Quote
Why do you use "--target=arm-elf" instead of"--target=arm-linux"?
Binutils make procedure did give that names. I don't want to go more in detail but did you build newlib as well? And, if you read my post carefully you will see that I failed with creating binutils by myself.
Title: Re: [Tutorial] Cross Compile for arm-linux
Post by: Kjooow on December 11, 2009, 06:47:06 pm
Quote
Why do you use "--target=arm-elf" instead of"--target=arm-linux"?
Binutils make procedure did give that names. I don't want to go more in detail but did you build newlib as well? And, if you read my post carefully you will see that I failed with creating binutils by myself.

But arm-elf is not arm-linux (e.g. http://sources.redhat.com/ml/crossgcc/2005-11/msg00028.html )... I don't know/understand...

If you try my steps:

Quote
Enable amr-linux cross compiling:

1) Compile binutils for arm-linux; if not already done, extract binutils-2.20.tar.gz in:
   ~/fpc_tools/binutils-2.20

2) cd ~/fpc_tools/binutils-2.20

3) ./configure --target=arm-linux --disable-werror

4) make

5) sudo make install

You will able to compile binutils "arm-linux-as, arm-linux-ar, arm-linux-ld, ..." yourself, so no other steps are necessarie to have binutils for arm-linux.

With this new "revision" (006) of first post, I can compile for arm-linux without errors and program runs on device. I can compile a "complex" example as "gp2x_tutorial", but I get linking error to -lSDL (i tried to add JediSDL to path, but maybe I'm mistaking something):

Code: [Select]
~/dev/gp2xdemo$ ppcarm gp2x_tutorial.dprFree Pascal Compiler version 2.5.1 [2009/12/11] for arm
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARM
Compiling gp2x_tutorial.dpr
Assembling gp2x_tutorial
Linking gp2x_tutorial
/home/kjow/lazarus/fpc/binutils/ld: cannot find -lSDL
gp2x_tutorial.dpr(137,45) Error: Error while linking
gp2x_tutorial.dpr(137,45) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

or with parameters:   -Xd -CaEABI -CfSOFT -CpARMV5

Code: [Select]
ppcarm  -Xd -CaEABI -CfSOFT -CpARMV5 gp2x_tutorial.dpr
Free Pascal Compiler version 2.5.1 [2009/12/11] for arm
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARM
Compiling gp2x_tutorial.dpr
Assembling gp2x_tutorial
Linking gp2x_tutorial
/home/kjow/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libSDL.so when searching for -lSDL
/home/kjow/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libSDL.a when searching for -lSDL
/home/kjow/lazarus/fpc/binutils/ld: cannot find -lSDL
gp2x_tutorial.dpr(137,45) Error: Error while linking
gp2x_tutorial.dpr(137,45) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

In Lazarus I get:

Code: [Select]
Recompiling WSLCLClasses, checksum changed for LCLProc
wslclclasses.pp(32,56) Fatal: Can't find unit WSLCLClasses used by LCLClasses
Title: Re: [Tutorial] Cross Compile for arm-linux
Post by: Kjooow on December 15, 2009, 12:16:21 pm
Big update at first post!

With these steps I can compile, assemble and almost link. Yes, I have a problem with two libraries:

All messages returned by Lazarus IDE:

/home/kjow/lazarus/fpc/libcross/libexpat.so.1: undefined reference to `__aeabi_unwind_cpp_pr1@GCC_3.5'
/home/kjow/lazarus/fpc/libcross/libglib-2.0.so: undefined reference to `__aeabi_unwind_cpp_pr0@GCC_3.5'
LAzARM.lpr(22) Error: Error while linking
LAzARM.lpr(22) Fatal: There were 1 errors compiling module, stopping


Do you know how to solve this undefined reference to `__aeabi_unwind_cpp_pr0@GCC_3.5'?
Title: Re: [Tutorial] Cross Compile for arm-linux
Post by: Kjooow on December 15, 2009, 04:07:00 pm
IT WORKS!!!  :o :D

I was in wrong simply with bad target libs :)
I made a copy of /lib and /usr/lib of Nokia N900 and renamed the libs "not found" (generally from libXXX.so.0.1234.1 to libXXX.so however Messages of IDE tells me everything)

Here the screenshot (http://img46.imageshack.us/i/kjowhelloworld.png/)!

Tutorial above is working at 100% on a new/fresh installation of Ubuntu 9.10 x86.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: alter on December 15, 2009, 04:23:13 pm
I never used Maemo but can't you simply use ldconfig to generate missing symlinks?
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on December 15, 2009, 04:34:44 pm
I never used Maemo but can't you simply use ldconfig to generate missing symlinks?

I don't know ldconfig, I'm not expert of linux develop and more less of cross compiling.
I grabbed libs needed from the device and now it build projects well :)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: danzman on December 21, 2009, 10:34:23 pm
Sorry for butting in. Have you guys done anything more than the "hello world"? I would love to make FPC/Lazarus work as I am more at home with Pascal. If we can do serious programming with FPC then we're in business 8)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on December 21, 2009, 10:41:05 pm
NOTE 1, on First post updated ;)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: danzman on December 22, 2009, 02:30:50 pm
I got my Ubuntu 9.10 box running with Lazarus already installed. I also have Maemo5 SDK installed with GTK and scratchbox. Everything I have on the box is my attempt to develop an app for Nokia N900. Would I have any problem adding FPC capability to develop app for N900?

Also, reading through the thread left me in a confused state. It could be my problem but can I impose on you gurus to rewrite your tutorial? Thanks. :-[
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on December 22, 2009, 02:44:38 pm
What thing confusing you?

With this tutorial you can build for maemo without maemo sdk/scratchbox. Follow first post step by step.

Lazarus and fpc you need are the daily source snapshot.

Other things on this thread are useless, you need to follow first post (or wiki tutorial) only:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: jdonth on January 03, 2010, 08:26:19 pm
I am trying to set this up to compile a fpc console program (Hello World) to run on a SheevaPlug running Ubuntu 9.04.

I have followed your instructions (twice) but when I run the test program, it will run under my host system, but not on the SheevaPlug. The results of the program on my host system is:
Code: [Select]
root@ubuntu:~/TestARM# ./TestARM
DATE 2010/01/03
FPCTARGET i386
FPCTARGETCPU i386
FPCTARGETOS Linux
FPCVERSION 2.5.1
root@ubuntu:~/TestARM#
and on the SheevaPlug:
Code: [Select]
Last login: Sun Jan  3 19:14:19 2010 from 192.168.1.94
root@ubuntu:~# /TestARM
-bash: /TestARM: cannot execute binary file
root@ubuntu:~#

Before I post unnecessary stuff, do you have any thoughts?

Thanks,
~Joe
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: alter on January 03, 2010, 08:55:43 pm
Not sure but it looks like you have application binary in ~/TestARM/TestARM file. In first case you are trying to execute executable file and that seems to work. In second case you are in ~ not in ~/TestARM. Also aren't you trying to execute i386 binary on ARM or something?
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Ocye on January 04, 2010, 09:25:24 am
Quote
it will run under my host system, but not on the SheevaPlug.
Sheeva has an ARM processor which I suppose you're no using at the host system.
Try "file ./TestARM" to see target platform (should be "ELF 32-bit LSB executable, ARM, ..." instead of "ELF 64-bit LSB executable, x86-64...") or use "readelf -h ./TestARM" (more detailed information).
PS: In reply #4 are my Sheeva specific notes on Kjooow tutorial. Good luck!
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS on January 07, 2010, 05:25:22 pm
Hello and thanks for tuto.
I have Lazarus 9.29 on Ubuntu 9.10, working fine.
Your tuto is for a complete fresh installation but how to install the arm libs and be sure that my Lazarus-fpc gonna still work ? (i have a lots of components installed so im a bit afraid to touch to my good working Lazarus.)  :o

Could you explain please how to install the arms libs on a working Lazarus system (without destroy it) ?

I meen, after arm libs install, is it possible to still compile for Linux, is it possible to choose between arm compil or linux compil ?
Many thanks.
 
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on January 08, 2010, 09:48:50 pm
Hi, for arm you need latest FPC revision. It is better a trunk revision (more updated).

I never tried to update an existing version of lazarus/FPC, but I think that you simply need to follow the "make" parts... compiling FPC for arm (and than Lazarus for arm) simply ADD the function to cross-compile. It doesn't replace nothing (I think), so in your project, you just need to choose the CPU target to switch between architectures.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS on January 08, 2010, 10:50:49 pm
Thanks Kjoow

Quote
Hi, for arm you need latest FPC revision. It is better a trunk revision (more updated).

Done.

Now, i dont find where to download FPC for arm for Linux (in Lazarus Snapshot only for Windows version)   :'(
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on January 09, 2010, 12:59:53 am
Thanks Kjoow

Quote
Hi, for arm you need latest FPC revision. It is better a trunk revision (more updated).

Done.

Now, i dont find where to download FPC for arm for Linux (in Lazarus Snapshot only for Windows version)   :'(

you don't need a precompiled package, but simply the sources of fpc :)
With the tutorial you will going to enable arm-linux cross compileing from FPC sources :)
Download the zip via freepascal site ;)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS on January 10, 2010, 07:09:00 pm
Hi Kjooow

I have followed your steps.

Quote
FPC for ARM:

1) cd ~/lazarus/fpc/2.5.1/

2) sudo make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=/home/kjow/lazarus/fpc/binutils/ OPT=-dFPC_ARMEL INSTALL_PREFIX=/usr

Ok, it has compiled without problems.
Now, i have tried to cross-compile the LCL and i get that message (from console: sudo startlazarus):

Quote
TMainIDE.ParseCmdLineOptions:
  PrimaryConfigPath="/home/fred/.lazarus"
  SecondaryConfigPath="/etc/lazarus"
Note: TDefinePool.CreateFPCSrcTemplate UnitSearchPath empty
[TExternalToolList.Run] CmdLine="/usr/bin/make clean all -w OS_TARGET=linux CPU_TARGET=arm()" WorkDir="/usr/share/lazarus/lcl"
make: Entering directory `/usr/share/lazarus/lcl'
Makefile:198: *** The Makefile doesn't support target arm()-linux, please run fpcmake first.  Stop.
make: Leaving directory `/usr/share/lazarus/lcl'
TExternalToolList.Run Exception: the process exited with error code 2
TMainIDE.DoBuildLazarus: Building standard components (LCL, SynEdit, CodeTools) failed.
LAZARUS END - cleaning up ...
[TMainIDE.Destroy] A
[TMainIDE.Destroy] B  -> inherited Destroy... TMainIDE
[TMainIDE.Destroy] END

Also when i try to compile a sample : fpc -Tlinux -Parm test.pas

Quote
fred@fred-laptop:~$ fpc -Tlinux -Parm test.pas
Fatal: Too many config files nested
Fatal: Compilation aborted
Error: /usr/local/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)

Of course fpc -Tlinux -Pi386 test.pas compile without problems.
And binutils was installed like you explain.

What is the problem ?

Thanks

PS1 Why everything must be so complicated with Lazarus ?

PS2 Write once, compile everywhere, ok but, please, why must it be so difficult to install a crosscompiler ?
Is it so difficult for the Lazarus team to write a unique script to install a crosscompiler.
Maybe Lazarus team have to choose something else than : Write once, compile everywhere...

PS3 Lazarus was done only for Gurus ?

PS4 Many thanks to Kjooow  :P to try to help us in that jungle.

PS5  >:(  >:D
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Marc on January 11, 2010, 01:37:40 am
Quote
fred@fred-laptop:~$ fpc -Tlinux -Parm test.pas
Fatal: Too many config files nested
...
I would first try to resolve this issue. I've never seen this and it doesn't sound right.

try running
Code: [Select]
fpc -Tlinux -Parm -va test.pas to figure out which configfiles are used.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS on January 11, 2010, 03:55:48 pm
Hello Marc and thanks to care about me.

Quote
fred@fred-laptop:~$ fpc -Tlinux -Parm -va test.pas
[0.002] Macro defined: FPC
[0.002] Macro defined: VER2
[0.002] Macro defined: VER2_5
[0.002] Macro defined: VER2_5_1
[0.002] Macro defined: RESSTRSECTIONS
[0.002] Macro defined: FPC_HASFIXED64BITVARIANT
[0.002] Macro defined: FPC_HASINTERNALOLEVARIANT2VARIANTCAST
[0.002] Macro defined: FPC_HAS_VARSETS
[0.002] Macro defined: FPC_HAS_VALGRINDBOOL
[0.002] Macro defined: FPC_HAS_STR_CURRENCY
[0.002] Macro defined: FPC_REAL2REAL_FIXED
[0.002] Macro defined: FPC_STRTOCHARARRAYPROC
[0.002] Macro defined: FPC_STRTOSHORTSTRINGPROC
[0.002] Macro defined: FPC_OBJFPC_EXTENDED_IF
[0.003] Macro defined: FPC_HAS_OPERATOR_ENUMERATOR
[0.003] Macro defined: FPC_HAS_UNICODESTRING
[0.003] Macro defined: FPC_RTTI_PACKSET1
[0.003] Macro defined: FPC_HAS_INTERNAL_ROX
[0.003] Macro defined: FPC_HAS_MEMBAR
[0.003] Macro defined: FPC_SETBASE_USED
[0.003] Macro defined: INTERNAL_BACKTRACE
[0.003] Macro defined: STR_CONCAT_PROCS
[0.003] Macro defined: FPC_HAS_FEATURE_SUPPORT
[0.003] Macro defined: CPUARM
[0.003] Macro defined: CPU32
[0.003] Macro defined: FPC_CURRENCY_IS_INT64
[0.003] Macro defined: FPC_COMP_IS_INT64
[0.003] Configfile search: /home/fred/.fpc.cfg
[0.003] Reading options from file /home/fred/.fpc.cfg
[0.003] Start of reading config file /home/fred/.fpc.cfg
[0.016] interpreting file option "#INCLUDE /etc/fpc.cfg"
[0.016] Reading options from file /etc/fpc.cfg
[0.016] Start of reading config file /etc/fpc.cfg
[0.054] interpreting file option "#"
[0.054] interpreting file option "# Example fpc.cfg for Free Pascal Compiler"
[0.054] interpreting file option "#"
[0.054] interpreting file option "# ----------------------"
[0.054] interpreting file option "# Defines (preprocessor)"
[0.054] interpreting file option "# ----------------------"
[0.054] interpreting file option "#"
[0.054] interpreting file option "# nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed"
[0.054] interpreting file option "#"
[0.054] interpreting file option "# -d is the same as #DEFINE"
[0.054] interpreting file option "# -u is the same as #UNDEF"
[0.054] interpreting file option "#"
[0.054] interpreting file option "#"
[0.055] interpreting file option "# Some examples (for switches see below, and the -? helppages)"
[0.055] interpreting file option "#"
[0.055] interpreting file option "# Try compiling with the -dRELEASE or -dDEBUG on the commandline"
[0.055] interpreting file option "#"
[0.055] interpreting file option "# For a release compile with optimizes and strip debuginfo"
[0.055] interpreting file option "#IFDEF RELEASE"
[0.055] interpreting file option "#WRITE Compiling Release Version"
[0.055] interpreting file option "#ENDIF"
[0.055] interpreting file option "# For a debug version compile with debuginfo and all codegeneration checks on"
[0.055] interpreting file option "#IFDEF DEBUG"
[0.055] interpreting file option "#WRITE Compiling Debug Version"
[0.055] interpreting file option "#ENDIF"
[0.055] interpreting file option "# set binutils prefix"
[0.055] interpreting file option "#IFNDEF CPUI386"
[0.055] interpreting file option "#IFNDEF CPUAMD64"
[0.055] interpreting file option "#DEFINE NEEDCROSSBINUTILS"
[0.055] Macro defined: NEEDCROSSBINUTILS
[0.055] interpreting file option "#ENDIF"
[0.055] interpreting file option "#ENDIF"
[0.055] interpreting file option "#IFNDEF linux"
[0.055] interpreting file option "#DEFINE NEEDCROSSBINUTILS"
[0.055] interpreting file option "#ENDIF"
[0.055] interpreting file option "#IFDEF FPC_CROSSCOMPILING"
[0.055] interpreting file option "#IFDEF NEEDCROSSBINUTILS"
[0.055] Handling option "-XParm-linux-"
[0.055] interpreting option "-XParm-linux-"
[0.055] interpreting file option "#include /usr/lib/fpc/fpc-cross.cfg"
[0.079] Reading options from file /usr/lib/fpc/fpc-cross.cfg
[0.079] Start of reading config file /usr/lib/fpc/fpc-cross.cfg
[0.090] interpreting file option "#if 2.5.1 = 2.5.1"
[0.090] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.090] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.091] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.101] interpreting file option "#if 2.5.1 = 2.5.1"
[0.101] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.101] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.101] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.101] interpreting file option "#if 2.5.1 = 2.5.1"
[0.101] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.101] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.101] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.101] interpreting file option "#if 2.5.1 = 2.5.1"
[0.101] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.101] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.101] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.101] interpreting file option "#if 2.5.1 = 2.5.1"
[0.101] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.101] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] interpreting file option "#if 2.5.1 = 2.5.1"
[0.102] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.102] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] interpreting file option "#if 2.5.1 = 2.5.1"
[0.102] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.102] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] interpreting file option "#if 2.5.1 = 2.5.1"
[0.102] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.102] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] interpreting file option "#if 2.5.1 = 2.5.1"
[0.102] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.102] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] interpreting file option "#if 2.5.1 = 2.5.1"
[0.102] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.102] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.102] interpreting file option "#if 2.5.1 = 2.5.1"
[0.102] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.103] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.103] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.103] interpreting file option "#if 2.5.1 = 2.5.1"
[0.103] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.103] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.103] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.103] interpreting file option "#if 2.5.1 = 2.5.1"
[0.103] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.103] Too many config files nested
[0.103] Compilation aborted
Error: /usr/local/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Marc on January 12, 2010, 01:18:21 am
This is where it is going wrong
Code: [Select]
...
[0.055] interpreting file option "#include /usr/lib/fpc/fpc-cross.cfg"
[0.079] Reading options from file /usr/lib/fpc/fpc-cross.cfg
[0.079] Start of reading config file /usr/lib/fpc/fpc-cross.cfg
[0.090] interpreting file option "#if 2.5.1 = 2.5.1"
[0.090] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
[0.090] Reading options from file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.091] Start of reading config file /usr/lib/fpc/2.5.1/fpc-cross.cfg
[0.101] interpreting file option "#if 2.5.1 = 2.5.1"
[0.101] interpreting file option "#include /usr/lib/fpc/2.5.1/fpc-cross.cfg"
...

The file /usr/lib/fpc/fpc-cross.cfg is including /usr/lib/fpc/2.5.1/fpc-cross.cfg that seems OK to me, but... this file /usr/lib/fpc/2.5.1/fpc-cross.cfg is including itself. Remove those lines

Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS on January 12, 2010, 10:27:42 pm
Hola Marc, you are TOO STRONG.

[0.050] Unitsearch: /usr/lib/fpc/2.5.1/units/arm-linux/rtl/system.ppu
[0.051] Searching file /usr/lib/fpc/2.5.1/units/arm-linux/rtl/system.ppu... found
[0.051] PPU Loading /usr/lib/fpc/2.5.1/units/arm-linux/rtl/system.ppu
[0.051] PPU Name: /usr/lib/fpc/2.5.1/units/arm-linux/rtl/system.ppu
[0.051] PPU Time: 2010/01/10 02:38:57
[0.051] PPU Flags: 192641
[0.051] PPU Crc: ABF44071
[0.051] PPU Crc: 0585A8F3 (intfc)
[0.051] PPU Crc: 6B7B25F8 (indc)
[0.051] Number of definitions: 3934
[0.051] Number of symbols: 11426
[0.070] Finished loading unit SYSTEM
[0.070] Searching file test.pas... found
[0.070] Searching file test.pas... found
[0.070] Registering new unit FPINTRES
[0.070] Load from TEST (implementation) unit FPINTRES
[0.070] Loading unit FPINTRES
[0.070] Unitsearch: fpintres.ppu
[0.070] Searching file fpintres.ppu... not found
[0.070] Searching file FPINTRES.PPU... not found
[0.070] Unitsearch: fpintres.pp
[0.070] Searching file fpintres.pp... not found
[0.070] Searching file FPINTRES.PP... not found
[0.070] Unitsearch: fpintres.pas
[0.070] Searching file fpintres.pas... not found
[0.070] Searching file FPINTRES.PAS... not found
[0.070] Unitsearch: /usr/lib/fpc/2.5.1/units/arm-linux/rtl/fpintres.ppu
[0.070] Searching file /usr/lib/fpc/2.5.1/units/arm-linux/rtl/fpintres.ppu... found
[0.070] PPU Loading /usr/lib/fpc/2.5.1/units/arm-linux/rtl/fpintres.ppu
[0.070] PPU Name: /usr/lib/fpc/2.5.1/units/arm-linux/rtl/fpintres.ppu
[0.070] PPU Time: 2010/01/10 02:38:57
[0.070] PPU Flags: 192641
[0.070] PPU Crc: B8DBE822
[0.070] PPU Crc: B8DBE822 (intfc)
[0.070] PPU Crc: 6B7B25F8 (indc)
[0.070] Number of definitions: 58
[0.070] Number of symbols: 169
[0.070] Load from FPINTRES (interface) unit SYSTEM
[0.070] Adding dependency: FPINTRES depends on SYSTEM
[0.070] Finished loading unit FPINTRES
[0.071] Searching file test.pas... found
[0.071] Registering new unit OBJPAS
[0.071] Load from TEST (implementation) unit OBJPAS
[0.071] Loading unit OBJPAS
[0.071] Unitsearch: objpas.ppu
[0.071] Searching file objpas.ppu... not found
[0.071] Searching file OBJPAS.PPU... not found
[0.071] Unitsearch: objpas.pp
[0.071] Searching file objpas.pp... not found
[0.071] Searching file OBJPAS.PP... not found
[0.071] Unitsearch: objpas.pas
[0.071] Searching file objpas.pas... not found
[0.071] Searching file OBJPAS.PAS... not found
[0.071] Unitsearch: /usr/lib/fpc/2.5.1/units/arm-linux/rtl/objpas.ppu
[0.071] Searching file /usr/lib/fpc/2.5.1/units/arm-linux/rtl/objpas.ppu... found
[0.071] PPU Loading /usr/lib/fpc/2.5.1/units/arm-linux/rtl/objpas.ppu
[0.071] PPU Name: /usr/lib/fpc/2.5.1/units/arm-linux/rtl/objpas.ppu
[0.071] PPU Time: 2010/01/10 02:38:57
[0.071] PPU Flags: 192643
[0.071] PPU Crc: 31D1BC29
[0.071] PPU Crc: 300797B1 (intfc)
[0.071] PPU Crc: 6B7B25F8 (indc)
[0.071] Number of definitions: 80
[0.071] Number of symbols: 147
[0.071] Load from OBJPAS (interface) unit SYSTEM
[0.071] Adding dependency: OBJPAS depends on SYSTEM
[0.071] Finished loading unit OBJPAS
[0.071] Searching file test.pas... found
[0.071] Parsing implementation of test.pas
[0.071] Handling switch "$I"
[0.071] Searching file test.pas... found
[0.071] Back in test.pas
[0.072] Handling switch "$I"
[0.072] Searching file test.pas... found
[0.072] Back in test.pas
[0.072] Handling switch "$I"
[0.072] Searching file test.pas... found
[0.072] Back in test.pas
[0.072] Handling switch "$I"
[0.072] Searching file test.pas... found
[0.072] Back in test.pas
[0.072] Handling switch "$I"
[0.072] Searching file test.pas... found
[0.072] Back in test.pas
[0.073] Unloading resource unit FPINTRES (not needed)
[0.073] Assembling test
[0.073] Searching file /home/fred/lazarus9.29/fpc/binutils/as... found
[0.073] Using assembler: /home/fred/lazarus9.29/fpc/binutils/as
[0.083] Searching file test.o... found
[0.083] Searching file /usr/lib/fpc/2.5.1/units/arm-linux/rtl/system.o... found
[0.095] Searching file /usr/lib/fpc/2.5.1/units/arm-linux/rtl/objpas.o... found
[0.096] Linking test
[0.096] Searching file prt0... not found
[0.096] Searching file prt0.o... not found
[0.096] Searching file PRT0.O... not found
[0.096] Searching file /usr/lib/fpc/2.5.1/units/arm-linux/rtl/prt0.o... found
[0.101] Searching file /home/fred/lazarus9.29/fpc/binutils/ld... found
[0.101] Using util /home/fred/lazarus9.29/fpc/binutils/ld
[0.125] 9 lines compiled, 0.1 sec
[0.125] 6 hint(s) issued
[0.125] 2 note(s) issued[/quote]

It works, Marc, it works, alleluia.  :P  :P  :P
Thaaaaanks
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS on January 12, 2010, 10:38:23 pm
Ooops, litle bemol.

I have tried to compile my real prog (+- 50.000 lines) with Lazarus but i get

Quote
No option inside /usr/lib/fpc/2.5.1/fpc-cross.cfg
Fatal: Cant find unit Interfaces used by miximum
  :'(

and if i try to cross-compile the LCL

Quote
[WARNING] Out of OEM specific VK codes, changing to unassigned
[WARNING] Out of unassigned VK codes, assigning $FF
TLazarusManager.Run starting /usr/share/lazarus/lazarus ...
[WARNING] Out of OEM specific VK codes, changing to unassigned
[WARNING] Out of unassigned VK codes, assigning $FF
TMainIDE.ParseCmdLineOptions:
  PrimaryConfigPath="/home/fred/.lazarus"
  SecondaryConfigPath="/etc/lazarus"
Note: TDefinePool.CreateFPCSrcTemplate UnitSearchPath empty
[TExternalToolList.Run] CmdLine="/usr/bin/make clean all -w OS_TARGET=linux CPU_TARGET=arm()" WorkDir="/usr/share/lazarus/lcl"
make: Entering directory `/usr/share/lazarus/lcl'
Makefile:198: *** The Makefile doesn't support target arm()-linux, please run fpcmake first.  Stop.
make: Leaving directory `/usr/share/lazarus/lcl'
TExternalToolList.Run Exception: the process exited with error code 2
TMainIDE.DoBuildLazarus: Building standard components (LCL, SynEdit, CodeTools) failed.


 :'(   :'(
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Marc on January 13, 2010, 01:56:51 am
Quote
CPU_TARGET=arm()

what do those () there ?

Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS 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
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: danzman 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?
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS 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.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS 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
 (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 (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  ::)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: danzman 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)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Fred vS 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
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: kattle87 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
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Ocye on March 02, 2010, 09:58:39 am
What does "ldd ./TestARM" report?
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: kattle87 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)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Ocye 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.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: kattle87 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)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: typo on March 17, 2010, 11:12:35 pm
There is a bounty of $ 500 for this task available on the Wiki:

http://wiki.lazarus.freepascal.org/Bounties#LAZARUS_RUNING_IN_A_LINUX_MACHINE_COMPILING_TO_ARM.2FLINUX_.24500_US_.3D.3D
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: marcov 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.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow 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 (http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM) is the only authritative tutorial!
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow 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.

:)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: thierrybo on May 16, 2010, 08:55:44 am
I can't extract files :( from lazarus.zip, either from Windows or Linux.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 16, 2010, 01:58:42 pm
Please, use latest version of 7-zip.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: thierrybo on May 17, 2010, 06:26:08 am
Thanks,

[rant]  :D
I will try that, but please use compress method where we do not have to use a specific tool version. On linux this is no a standard program, and if so we also do not have necessarily the last version in repositories [/rant].

By the way, how do you "run" you graphical example on  you phone. I used you tutorial to do the same thing on Android emulator (from Android SDK) and I can run console programs that run in android shell FROM the computer, but not from phone screen (inside emulator).
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 17, 2010, 07:00:44 am
Thanks,

[rant]  :D
I will try that, but please use compress method where we do not have to use a specific tool version. On linux this is no a standard program, and if so we also do not have necessarily the last version in repositories [/rant].

By the way, how do you "run" you graphical example on  you phone. I used you tutorial to do the same thing on Android emulator (from Android SDK) and I can run console programs that run in android shell FROM the computer, but not from phone screen (inside emulator).

Thanks for suggestion ;)
BTW, android is not a real arm-linux machine, so I can't test/help... this tutorial/these scripts is/are for arm-linux machines (like Nokia N900's maemo and, hopefully, for the future MeeGo)
Title: quest for arm compilation
Post by: warcode on May 17, 2010, 01:06:19 pm
Hi all

i'm trying to make a simple gtk1 or gtk2 for the arm cpu. I'm using a Overo™ Air COM (OMAP 3503 Application Processor with ARM Cortex-A8 CPU) + a 4,3 lcd touchscreen. I'm on ubuntu 10.04 and i dont have installed fpc or lazarus with package manager (synaptic). I using the 2 script here: lazarus_first_time and lazarus_update for getting lazarus + fpc installed on my /home/~ folder

After lauch lazarus_first_time everything look ok, when i try to compli a simple empty form i got this type of error

/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.a when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: cannot find -lX11
mb_scan.lpr(16,46) Error: Error while linking
mb_scan.lpr(16,46) Fatal: There were 1 errors compiling module, stopping

What i miss or what i need to make for complet the compilation
Thanks for any help

Christian F
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 17, 2010, 01:17:34 pm
It seems to be all ok.
So, as there's wrote at the end of "lazarus_first_time" script execution, you need to follow the rest of the tutorial from here:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Configure_Lazarus_for_cross_Compile

 :)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: warcode on May 17, 2010, 01:39:54 pm
Hi Kjooow

So after make  lazarus_first_time and lazarus_update i need only to start with Configure Lazarus for cross Compile  on the wiki ?

Set Targets

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



Add target libs to your project
REMEMBER TO CHANGE EVERY /home/user/ WITH YOUR OWN USER PATH!

    * From the IDE:
         1. Set in Project / Compiler Options / Linking / Options (-k): -L/home/user/lazarus/fpc/libcross
This option have changed on the latest svn version or i can find linking option ? And when i go on my lazarus folder this is what i have
/lazarus/fpc/2.5.1   and i have no libcross folder here


         2. Set in Project / Compiler Options / Compilation / Execute after / Command: arm-linux-strip -s /path/to/your/project/binary (where "binary" is the executable builded with Lazarus)

Thanks for help me

Christian F
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Ocye on May 17, 2010, 01:42:53 pm
Quote
...skipping incompatible /usr/lib/libX11.a when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: cannot find -lX11

Your libX11 located at /usr/lib isn't compatible. Additionally, you don't have one in your toolchain. Binutils and Newlib are needed.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: warcode on May 17, 2010, 01:45:02 pm
Thanks for the help guys

So where i can download X11 arm compatible (Binutils and Newlib)

Christian F
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 17, 2010, 01:49:57 pm
lazarus_first_time is meant to be used just first time, once the script ended you need to follow the tutorial from "Configure Lazarus for cross Compile" from the end of page.

Don't forget the Appendix B!

In the "Appendix B" there are the instructions to find and solve the "problem" of incompatible libs. (In other words you need the target libs to permit lazarus to link these at your binary)

lazarus_update is designed for daily use, so when you run this script fpc and lazarus will be updated to the latest svn automatically.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: warcode on May 17, 2010, 02:16:53 pm
Ok

1: I got the folder lib and /usr/lib (OMAP 3503 SD card) copied on /home/lazarus/libcross
2: added -L/home/user/lazarus/fpc/libcross
3: installed Newlib from synaptic
4: Build LCL + Package registration + press build (Lazarus will restart ? , because it' s not here )

i got the same error

/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.a when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: cannot find -lX11
project1.lpr(16,32) Error: Error while linking
project1.lpr(16,32) Fatal: There were 1 errors compiling module, stopping

Does i need to have a folder named lib and one named usr/lin in libcross
I' m a bit lose
Thanks for help
Christian F
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 17, 2010, 02:20:27 pm
Do you have checked the Set in Project / Compiler Options / Linking / Options (-k)?

I meant: not only add "-L/home/user/lazarus/fpc/libcross", but check the checkbox "Options (-k)"
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: warcode on May 17, 2010, 03:24:52 pm
Yep

I have a checkbox in option (-k) and -L/home/warlock/lazarus/fpc/libcross in the input
i can compile & run the testarm.pas witout trouble, i think that my probleme in fpc that can' t locate the X11 version arm that i copied in /home/warlock/lazarus/fpc/libcross. In this folder (libcross) i have a folder named X11 so i dont understand what is the error

Thanks for the help

Christian F




Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 17, 2010, 03:31:57 pm
you need to merge all file of all subdirs to /home/warlock/lazarus/fpc/libcross

So you will have a directory ( /home/warlock/lazarus/fpc/libcross ) which contains all files, without sub-folders.

This isn't an elegant mode, but it works. When I'll have more time I'll try to make this section of the tutorial more clear e more elegant.

e.g.

...
...
...
15/12/2009  15:30            78.048 librtcom-eventlogger.so.0.0.0
15/12/2009  15:30            17.672 libscconf.so.0
15/12/2009  15:30            17.672 libscconf.so.0.1
15/12/2009  15:28           329.492 libSDL-1.2.so.0
15/12/2009  15:28           329.492 libSDL-1.2.so.0.11.1
15/12/2009  15:28            70.548 libSDL_gfx.so.13
15/12/2009  15:28            70.548 libSDL_gfx.so.13.5.1
15/12/2009  15:28            38.916 libSDL_image-1.2.so.0
15/12/2009  15:28            38.916 libSDL_image-1.2.so.0.1.3
15/12/2009  15:28           249.932 libSDL_mixer-1.2.so.0
15/12/2009  15:28           249.932 libSDL_mixer-1.2.so.0.2
15/12/2009  15:28           249.932 libSDL_mixer-1.2.so.0.2.4
15/12/2009  15:28            10.300 libSDL_net-1.2.so.0
15/12/2009  15:28            10.300 libSDL_net-1.2.so.0.0.7
15/12/2009  15:28            17.992 libSDL_ttf-2.0.so.0
15/12/2009  15:28            17.992 libSDL_ttf-2.0.so.0.6.3
15/12/2009  15:43             9.700 libSegFault.so
15/12/2009  15:30            13.680 libshadowapp.so.0
...
...
...
15/12/2009  15:30           125.408 libwbxml2.so.0
15/12/2009  15:30           125.408 libwbxml2.so.0.0.0
15/12/2009  15:30           144.624 libwidgetutils.so
15/12/2009  15:30           144.624 libwidgetutils.so.0
15/12/2009  15:30           144.624 libwidgetutils.so.0.0.0
15/12/2009  15:30            18.524 libwl1251.so.0
15/12/2009  15:30            18.524 libwl1251.so.0.0.0
15/12/2009  15:30           100.640 libwpeditor.so.0
15/12/2009  15:30           100.640 libwpeditor.so.0.0.0
15/12/2009  15:28           945.616 libX11.so
15/12/2009  15:28           945.616 libX11.so.6
15/12/2009  15:28           945.616 libX11.so.6.2.0
15/12/2009  15:28             8.336 libXau.so.6
15/12/2009  15:28             8.336 libXau.so.6.0.0
15/12/2009  15:30            20.756 libxcb-randr.so.0
15/12/2009  15:30            20.756 libxcb-randr.so.0.0.0
15/12/2009  15:30             5.840 libxcb-shm.so.0
15/12/2009  15:30             5.840 libxcb-shm.so.0.0.0
15/12/2009  15:30            18.516 libxcb-xv.so.0
15/12/2009  15:30            18.516 libxcb-xv.so.0.0.0
15/12/2009  15:30            88.100 libxcb.so.1
15/12/2009  15:30            88.100 libxcb.so.1.0.0
...
...
...
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: warcode on May 17, 2010, 03:44:29 pm
So i need to copy only .so , .so.0 , .so.1 , ect file in libcross right ?
if yes do you know a linux command for copy my lib + usr/lib (arm folder) to my libcross ?

After try all what you telling me this what i got

/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /home/warlock/lazarus/fpc/libcross/libX11.so when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /home/warlock/lazarus/fpc/libcross/libX11.a when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.a when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: cannot find -lX11
project1.lpr(16,32) Error: Error while linking
project1.lpr(16,32) Fatal: There were 1 errors compiling module, stopping

i rename libX11.so.6.3.0 to libX11.so but witout effect
i search for a file libX11.a but find anyting in libcross



i wish i will be able to compile my first arm +gtk2 application today :)

Christian F
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 17, 2010, 04:06:17 pm
Try with:

mkdir /media/sd/libcross/
cp /lib/* /media/sd/libcross/
cp /usr/lib/* /media/sd/libcross/

Where /media/sd/ is the path of the sd on your arm device. Then put the SD on the pc :)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 17, 2010, 04:14:47 pm
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /home/warlock/lazarus/fpc/libcross/libX11.so when searching for -lX11

i rename libX11.so.6.3.0 to libX11.so but witout effect
i search for a file libX11.a but find anyting in libcross

From:
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
to:
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /home/warlock/lazarus/fpc/libcross/libX11.so when searching for -lX11

Now the linker uses the right folder to search libraries: /home/warlock/lazarus/fpc/libcross/

But there are still incompatible. It seems that your target libs aren't the right ones.
Do you have grabber these files from the arm-device or from the pc-linux?

The target libs must be arm-linux compiled...
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: warcode on May 17, 2010, 04:21:43 pm
This is what i make

cp /media/1b1f83d3-c5f0-44b0-ae17-21b401cd081b/lib/* /home/warlock/lazarus/fpc/libcross/
cp /media/1b1f83d3-c5f0-44b0-ae17-21b401cd081b/usr/lib/* /home/warlock/lazarus/fpc/libcross/

but i get the same error

/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.a when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: cannot find -lX11
project1.lpr(16,32) Error: Error while linking
project1.lpr(16,32) Fatal: There were 1 errors compiling module, stopping

Does i need to make clean & make ? i have a  /etc/fpc.cfg and a home/warlock/.fpc.cfg everthing is ok here ?
i will restart from beginning again :)
plz loading ...

Christian F




Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 17, 2010, 05:32:03 pm
This is what i make

cp /media/1b1f83d3-c5f0-44b0-ae17-21b401cd081b/lib/* /home/warlock/lazarus/fpc/libcross/
cp /media/1b1f83d3-c5f0-44b0-ae17-21b401cd081b/usr/lib/* /home/warlock/lazarus/fpc/libcross/

but i get the same error

/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.a when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: cannot find -lX11
project1.lpr(16,32) Error: Error while linking
project1.lpr(16,32) Fatal: There were 1 errors compiling module, stopping

Does i need to make clean & make ? i have a  /etc/fpc.cfg and a home/warlock/.fpc.cfg everthing is ok here ?
i will restart from beginning again :)
plz loading ...

Christian F

It seems that your lazarus doesn't use the right path again...

if the error is: /home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/etc. etc.
it doesn't use the right path

if the error is: /home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /home/warlock/lazarus/fpc/libcross/etc. etc.
it uses the right path, but it doesn't use the right libs.

I don't know why, on your installation, sometimes the path is right, sometimes not...
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: warcode on May 17, 2010, 06:09:36 pm
I got it finnaly i was able to compile a simple form for ARM Youpi and thanks for the help.
After pass 30 min to rename a buch of so.0.2 -> .so everything is ok now

My main application is a shop barcode scanner using overo air (wireless & bluetooth)
This application need to connect to a mysql5 database on my locale network so i'm using a TMySQL50Connection , ect  this application only have a few button and this compoment. when i try to compile it i got this

registersqldb.pas(45,3) Fatal: Can't find unit propedits used by registersqldb

Can someone give me a tpis on how using mysql database and arm ?

Many Thanks again for the help
Christian F
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Kjooow on May 17, 2010, 06:23:14 pm
I got it finnaly i was able to compile a simple form for ARM Youpi and thanks for the help.
After pass 30 min to rename a buch of so.0.2 -> .so everything is ok now

My main application is a shop barcode scanner using overo air (wireless & bluetooth)
This application need to connect to a mysql5 database on my locale network so i'm using a TMySQL50Connection , ect  this application only have a few button and this compoment. when i try to compile it i got this

registersqldb.pas(45,3) Fatal: Can't find unit propedits used by registersqldb

Can someone give me a tpis on how using mysql database and arm ?

Many Thanks again for the help
Christian F


I'm glad to know that it works now.

The component that you use for mysql, works well con i386-linux compiling?
If yes, try to recompile LCL and Package registration:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Configure_Lazarus_for_cross_Compile
(paragraph "Configure Lazarus for cross Compile" only)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: thierrybo on May 17, 2010, 07:36:49 pm
Hi,

after experimenting I have some suggestions to improve wiki :

- Binutils.

I don't understand how yo install them. You unpack in one directory, install in a second directory (default location), then link back from there to a third directory. Just install in the base directory you choose for toolchain. For the directories assume you have sources in ~/lazarus/fpcsrc and install all binaries in ~/lazarus/fpc :

Code: [Select]
./configure --target=arm-linux --disable-werror --prefix=~/lazarus/fpc/binutils
make
make install


- Compile FPC from sources.

I think this part is over complicated. As for binutils, you install is /usr/, then you have some lines to erase/replace some older files with the new one from source, then link some files back to you home directory.  Either install in /usr/local/ or /opt/ or somewhere in you home folder. For example say we install in ~/lazarus/fpc as above

Code: [Select]
cd ~/lazarus/fpcsrc
make all OPT='-gl -O3p3' PP=/usr/bin/ppc386
make install FPC=/usr/bin/ppc386 INSTALL_PREFIX=~/lazarus/fpc
ln -s ~/lazarus/fpcsrc/lib/fpc/2.5.1/ppc386 ~/lazarus/fpc/bin/ppc386

- FPC for ARM

It would be useful to indicate that it is safe to install a crosscompiler in the same directory as regular freepascal.  When you crossinstall, make does not copy anything in the /bin directory, only units for the new $TARGET in  /lib/fpc/$FPCVERSION/units/$FPCTARGET and the new compiler in /lib/fpc/$FPCVERSION/newcrosscompiler.

Also using BINUTILSPREFIX combined with a masterfully created fpc.cfg we can build a powerful crosscompiling system that autoselect the right targets and avoid to set manually some options :

Code: [Select]
cd ~/lazarus/fpcsrc/
make clean crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=~/lazarus/fpc/binutils/bin BINUTILSPREFIX=arm-linux- OPT=-dFPC_ARMEL INSTALL_PREFIX=~/lazarus/fpc PP=/usr/bin/ppc386

ln -s ~/lazarus/fpc/lib/fpc/2.5.1/ppcrossarm ~/lazarus/fpc/bin

- fpc.cfg

it is simpler to use a whole fpc.cfg in your home directory than to use INCLUDE, it is confusing. Either edit /etc/fpc.cfg or use ~/.fpc.cfg.

With the following fpc.cfg excerpt ( most retrieved from the default one installed with deb packages from freepascal site) you cover almost all situations and you don't need to specify -k and -L options in Lazarus, they will be automatically selected.

Code: [Select]
#IFNDEF CPUI386
  #IFNDEF CPUAMD64
    #DEFINE NEEDCROSSBINUTILS
  #ENDIF
#ENDIF


#IFNDEF linux
  #DEFINE NEEDCROSSBINUTILS
#ENDIF


#IFDEF FPC_CROSSCOMPILING
  #IFDEF NEEDCROSSBINUTILS
    # other binutils directory if processor or target OS differs
    -FD/home/USER/lazarus/fpc/binutils/bin
    #set prefix to select the right ones from that directory
    -XP$fpctarget-
    # other library
    -Fl/home/user/lazarus/fpc/libcross
  #ENDIF NEEDCROSSBINUTILS
#ENDIF

#IFDEF VER2_2_4
  #IFDEF FPCAPACHE_1_3
  -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd13/
  #ELSE
  #IFDEF FPCAPACHE_2_0
    -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd20
  #ELSE
    -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd22
  #ENDIF
  #ENDIF
  
  # searchpath for units and other system dependent things
  -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
  -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
  -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl

#ELSE
#++++++++++++++++++++++++++++++++++++++++++++++++++++
# for custom FPC version installed in ~/lazarus/fpc
#++++++++++++++++++++++++++++++++++++++++++++++++++++
  #IFDEF FPCAPACHE_1_3
  -Fu/home/USER/lazarus/fpc/lib/fpc/$FPCVERSION/units/$FPCTARGET/httpd13/
  #ELSE
  #IFDEF FPCAPACHE_2_0
    -Fu/home/USER/lazarus/fpc/lib/fpc/$FPCVERSION/units/$FPCTARGET/httpd20
  #ELSE
    -Fu/home/USER/lazarus/fpc/lib/fpc/$FPCVERSION/units/$FPCTARGET/httpd22
  #ENDIF
  #ENDIF

  # searchpath for units and other system dependent things
  -Fu/home/USER/lazarus/fpc/lib/fpc/$FPCVERSION/units/$FPCTARGET
  -Fu/home/USER/lazarus/fpc/lib/fpc/$FPCVERSION/units/$FPCTARGET/*
  -Fu/home/USER/lazarus/fpc/lib/fpc/$FPCVERSION/units/$FPCTARGET/rtl

#ENDIF

# searchpath for libraries
#ifdef cpux86_64
  -Fl/usr/lib/gcc/x86_64-linux-gnu/4.3.3
#endif


#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.3.3
#endif

 - Lazarus

Stripping after build. If you set proper compiler options you do not need this, check -CX -XX and uncheck all in Degugging group excepting -Xs.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Giarados on May 18, 2010, 06:33:37 pm
Hi to everybody. I ve been trying to get the compiler working for three days...:( i ve been following your guide and apparently nothing went wrong..the problem is that i m unable to crosscompile any source for arm. could you help me? i don't get any error message while compiling binutils and fpc..(i m not interested in using lazaraus, just need fpc..)

thanks ;)

EDIT:
I would need to download the correct zip package..now it is unavailable..using the svn repository the procedure doesn't work maybe because the directory tree is different..could anyone help me?
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: avra on November 30, 2010, 09:36:29 am
CodeTyphon seems to be an easy solution for all newbies interested in cross compiling.
http://www.pilotlogic.com/sitejoom/index.php?option=com_content&view=article&id=96&catid=68&Itemid=147

Quote
• 4 CPU-Operating Systems Host Layers (Win32, Win64, Linux32, Linux64).
• 16 CPU-Operating Systems Target Layers.
• Win64 Layer has Dual Personality (Win64 and Win32).
• Win32 Layer is Cross-Build Center with Cross Elements for:
    arm-Wince
    arm-Linux
    arm-Embedded  (freepascal only)
    arm-gba            (freepascal only)
    arm-nds            (freepascal only)
    i386-Win32
    i386-Linux
    i386-FreeBSD
    i386-Haiku         (freepascal only)
    x86_64-Win64
    x86_64-Linux
    x86_64-FreeBSD
    powerpc-Linux
    powerpc64-Linux  (freepascal only)
    sparc-Linux
    sparc-Solaris      (freepascal only)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: SONFEDAI on December 09, 2010, 12:15:01 pm
iPhone Developing on Windows32 with Lazarus :)

is it Possible?
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Phil on December 11, 2010, 05:50:44 pm
You can't develop for iOS on Windows with any IDE, not just Lazarus, because Apple's tools only run on OS X.

Thanks.

-Phil
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: marcov on December 13, 2010, 02:15:23 pm

This is what i make

cp /media/1b1f83d3-c5f0-44b0-ae17-21b401cd081b/lib/* /home/warlock/lazarus/fpc/libcross/
cp /media/1b1f83d3-c5f0-44b0-ae17-21b401cd081b/usr/lib/* /home/warlock/lazarus/fpc/libcross/

but i get the same error

/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: skipping incompatible /usr/lib/libX11.a when searching for -lX11
/home/warlock/lazarus/fpc/binutils/ld: cannot find -lX11

In my crosscompiling snapshot I have:

#ifdef cpuarm
-XR/libraryimages/sheevaplug
#-CfSOFT
-dFPC_ARMEL
-Cparmv5
#-k"-mabi=apcs-gnu"
#-k"-mfpu=fpa"
#-CaEABI
-dusecthreads
-Fl/libraryimages/sheevaplug/lib
-Fl/libraryimages/sheevaplug/usr/lib
#endif

the important one here is the -XR which together with the --prefix of compiling the binutils (see below) prevented NOT searching libraries in normal dirs, and DO search dirs in the copied dirs. The -Fl's might be redundant, just like the many commented commands.
 
moreover, depending on what I am compiling for I had to set the eabi version for the assembler. I suspect the "default" eabi might work depending on which target
you used to compile your binutils (gnu-eabi is eabi 5 afaik, arm-elf is 0. I need 4 :-)

For that, on *nix (freebsd) I rename the assembler to arm-linux-as2, and make a shellscript arm-linux-as containing:

#/usr/bin/env bash
arm-linux-as2 -meabi 4 $*

For windows I use this pascal wrapper program:

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/install/cross/aswrapper.pas?view=markup&revision=824&root=fpcbuild


my snapshot is then compiled with

----------------------------------
#!/usr/bin/env bash

PATH=/home/marcov/armelfbinutils:$PATH
export PATH

cd fpc
make crosszipinstall CPU_TARGET=arm OS_TARGET=linux OPT="-dFPC_ARMEL" CROSSOPT="-XR/libarm -dFPC_ARMEL -CfSOFT -Cparmv5" FPC=~/ppcrel
-----------

and the binutils were made using:

--------------------------------------------
#!/usr/bin/env bash

# 1. extract the binutils 2.20 .tar.bz2
#     tar xvjf binutils-2.20.tar.bz2 in the dir where it is residing now
# 2. apply the as.h.diff patch to <extractedbinutils>/gas/as.h
# 3. run this shell script
# 4. some additional renaming of the arm,as,ld (or *-new) might be necessary

# setting static

LD_FLAGS="${LD_FLAGS} -static"
LDFLAGS="${LD_FLAGS} -s"
CFLAGS="${CFLAGS} -static"
CPPFLAGS="${CPPFLAGS} -static"
CXXFLAGS="${CXXFLAGS} -static"

# configure binutils

../binutils-2.20/configure --disable-nls --disable-shared --target=arm-elf --prefix /usr/cross/

# build binutils

make

# collect binaries

TARGETDIR=/home/jerome/armelfbinutils/

mkdir -p $TARGETDIR
find . -perm /u+x -type f |grep -v status |xargs -Ireplfilename cp replfilename $TARGETDIR
--------------------

Note that the prefix is important since it seems to stop the resulting binutils from searching the normal dirs.

Sometimes compiling binutils doesn't work, (a common problem gcc version related afaik), and then I use this patch:
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.64
retrieving revision 1.64.2.1
diff -u -r1.64 -r1.64.2.1
--- src/gas/as.h   2009/09/03 12:54:21   1.64
+++ src/gas/as.h   2009/12/03 10:40:25   1.64.2.1
@@ -238,7 +238,7 @@
 #define know(p) gas_assert(p)   /* Verify our assumptions!  */
 #endif /* not yet defined */
 #else
-#define know(p)         /* know() checks are no-op.ed  */
+#define know(p)   do {} while (0)   /* know() checks are no-op.ed  */
 #endif
 
 /* input_scrub.c */
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Jnny_CN on December 31, 2010, 04:42:57 am
i was successfuly get fpc gui apps run on real s3c6410 hardware with your wiki ,thanks

i use crosstoolschain "arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2" downloads from http://www.codesourcery.com/

with this toolchain i cross compile fpc 2.5.1 for armv5 arch

then use the fpc 2.5.1 for armv5 arch cross compile the LCL and Package

within scratchbox i cross compile the xorg server and gtk library

so all needed thing get ready,

then set the right compiler and library path with your wiki

now i can use Lazarus IDE make my gui apps run and debug under the host(win32 or linux-i386) then cross compile it under linux-i386 ,finally copy to the real hardware get it run well.

these are the main steps i have done

fpc+Lazarus is great ,it make me for more easier to write gui apps on embedded linux

than use gtk or wxwidgets(wxGTK) write gui apps on embedded linux.

thanks guys



Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Marcovaldo on January 27, 2011, 03:01:11 pm
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM

Hello Kjooow,

1st thx for the script (helping such newbies like me out)!

I used a virtual Ubuntu 9.10 (under VMWare, updated)
and the script ran through OK (throwing lots of warnings, but I think this
might be normal)

Under Lazarus and under fpc from the command line, I have difficulties
with the chaining to the assembler:
Quote
Free Pascal Compiler version 2.5.1 [2011/01/26] for arm
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Linux for ARMEL
Compiling test1.lpr
Assembling test1
test1.lpr(15,16) Error: Assembler /home/kra/lazarus/fpc/binutils/as not found, switching to external assembling
test1.lpr(15,16) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/local/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)

The X-flags etc of as look OK. I can call fpc with -s and manually
feed the results to as. This works.

usr/local/bin looks OK
Quote
.........
-rwxr-xr-x 1 root root      54 2011-01-27 05:19 arm-linux-as
-rwxr-xr-x 2 root root 3840999 2011-01-26 09:47 arm-linux-as_org
lrwxrwxrwx 1 root root      29 2011-01-26 10:00 ppcarm -> /usr/lib/fpc/2.5.1/ppcrossarm
kra@ubuntu910desktop:/usr/local/bin$ cat arm-linux-as
#!/bin/sh
/usr/local/bin/arm-linux-as_org -meabi=5 $@
kra@ubuntu910desktop:/usr/local/bin$

and /home/user/lazarus/fpc/binutils look also OK
Quote
lrwxrwxrwx 1 kra kra 27 2011-01-26 09:47 ar -> /usr/local/bin/arm-linux-ar
lrwxrwxrwx 1 kra kra 27 2011-01-27 07:08 as -> /usr/local/bin/arm-linux-as
lrwxrwxrwx 1 kra kra 27 2011-01-26 09:47 ld -> /usr/local/bin/arm-linux-l

Any idea what might went wrong?

Marcovaldo
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: marcov on January 27, 2011, 10:10:51 pm

Any idea what might went wrong?


Add -XParm-linux-
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Marcovaldo on January 27, 2011, 11:03:17 pm
Add -XParm-linux-

That worked!

Thank you very much for your fast help!!!

Kind greetings from Vienna,

  Marcovaldo
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: fourfive on April 14, 2011, 08:19:00 am
Hello fpc-Arm-Linux-guys,

is there anyone out there, who tried do run the crosscompiler-script in the recent days? It seems that some links in Kjooows script are broken, especially the file

ftp.freepascal.org/pub/fpc/dist/2.5.1/i386-linux/rpm/fpc-2.5.1-1.i686.rpm

is not available. I will try to do the job manually with the related fpc.zip.

fourfive

Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: fourfive on April 14, 2011, 11:23:12 am
Some other issues concerning this theme:

Now i did the job manually along the wiki. Even here i detected some error:

Compiling the fpc2.5.1 from sources needs Version > FPC2.4.0, indicated 2.2.0 gives the message: use fpc version > 2.4.0.

Furthermore crosscompiling fpc2.5.1 for arm stopps with an error.

BTW: Trying CodeTyphons solution results in some errors, too and does not produce a usable cross-compiler for arm-linux.

In respect to some other problems, i.e the unreliable compatibility to the libraries of the linux-targets i wonder, wether it would be better to port our (30.000 line) project to such an unbeloved target as wince.

fourfive
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: DirkS on April 14, 2011, 11:52:25 am
Quote
Compiling the fpc2.5.1 from sources needs Version > FPC2.4.0, indicated 2.2.0 gives the message: use fpc version > 2.4.0.
It's mentioned in the docs that you should always use the previous stable version to compile the compiler from sources. So for (cross-) compiling 2.5.1 svn you should use fpc 2.4.2.

Quote
Furthermore crosscompiling fpc2.5.1 for arm stopps with an error.
Yes, I had the same problem about a week ago cross-compiling for arm-wince. It does happen occasionnally that it gets broken but is generally fixed fairly quickly.

Gr.
Dirk.
Title: Need help for crosscompiling
Post by: sfischer on September 02, 2011, 04:39:06 pm
Hello,

I've set up my crosscompiling environment on ubuntu. I've used the script lazarus_first_time.
I can successfully compile a helloworld.pas program. I've copied the binary file to the following ARM platform: http://opengear.com/product-acm5000.html
But i can't run it. the error message is segmentation fault.

After that, I've installed the CDK from Opengear
pls. see: http://community.pachube.com/node/690

I'm able to compile and link a c program. I can run the c program on the Target Device.
The Dev Kit from Opengear installs a different version of binutils
(Linker Assembler ...) but these tools are incompatible with FPC. (FPC can not use them, if I compile helloworld.pas)

The Dev Kit from Opengear can not work with the FPC Binutils.

So I'm in a trap. How to solve that problem ?

Thanks,
SF


 
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: tintinux on December 20, 2011, 06:02:21 pm
Hi

I try to use the script lazarus_first_time on a new (virtual) machine.

The directory  /home/$NAME/fpc_tools/binutils/binutils-2.20.1/  is renamed to /home/$NAME/fpc_tools/ and later there is a cd and commands into the old directory name. This can't work...

I do not know what is right...

Code: [Select]
[b]mv /home/$NAME/fpc_tools/binutils/binutils-2.20.1/ /home/$NAME/fpc_tools/[/b]

cd /home/$NAME/
#swap --> Please, use one of these combinations: "FPC 2.4.2 + Lazarus 0.9.30 -> fixes" OR "FPC 2.5.1 + Lazarus 0.9.31 -> trunk"
svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus
#svn co http://svn.freepascal.org/svn/lazarus/branches/fixes_0_9_30/ lazarus
cd /home/$NAME/lazarus/
svn up

cd /home/$NAME/lazarus/components/
svn co https://glscene.svn.sourceforge.net/svnroot/glscene/trunk glscene

echo "Install & Configure Binutils"
[b]cd /home/$NAME/fpc_tools/binutils-2.20.1[/b]
./configure --target=arm-linux --disable-werror
make
sudo make install

By the way, it would be useful to update 0.9.30 to 0.9.30.2 since the last one is the last stable release.

I have made small improvements in the script :

1) to avoid changes in 3 different places
2) to include a debug mode to be able to see error messages

If you are interested it is attached.

HTH
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: sngha2 on December 23, 2011, 10:07:42 am
Quote
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).
Do not run these scripts, they complete messed-up my Lazarus and FPC configuration and it took me half a day to clean up and re-install everything.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: tintinux on December 23, 2011, 10:14:38 am
Quote from: sngha2
Do not run these scripts
True, I had the same issue and I had to reinstall Lazarus from scratch.

When trying such things, it is advisable to use a VirtualBox as I did the second time (and found reported errors).

Regards
Tintinux


Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: kc87654321 on July 03, 2012, 07:52:51 am
I got it finnaly i was able to compile a simple form for ARM Youpi and thanks for the help.
After pass 30 min to rename a buch of so.0.2 -> .so everything is ok now

My main application is a shop barcode scanner using overo air (wireless & bluetooth)
This application need to connect to a mysql5 database on my locale network so i'm using a TMySQL50Connection , ect  this application only have a few button and this compoment. when i try to compile it i got this

registersqldb.pas(45,3) Fatal: Can't find unit propedits used by registersqldb

Can someone give me a tpis on how using mysql database and arm ?

Many Thanks again for the help
Christian F


I'm glad to know that it works now.

The component that you use for mysql, works well con i386-linux compiling?
If yes, try to recompile LCL and Package registration:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Configure_Lazarus_for_cross_Compile
(paragraph "Configure Lazarus for cross Compile" only)

hi !I got it finnaly and  thanks for the Setup_Cross_Compile_For_ARM.
 ;)My main application need The component ¨Lnet ¨,i try to recompile LCL and Package registration:Configure Lazarus for cross Compile,but ¨/home/user/lazarus/fpc/inet0.6.6/lib/lcommon.pp(537) Error: Assembler /home/user/lazarus/fpc/binutils/as not found, switching to external assembling¨, %) %) %)
plc tall me how can i use the  component ¨Lnet ¨ :'(

Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Leledumbo on July 03, 2012, 08:50:43 am
Quote
Error: Assembler /home/user/lazarus/fpc/binutils/as
Do you have cross arm binutils installed? If yes, how are they named? If it's something like i386-linux-<name>, probably you need to adjust the fpc.cfg to have -XP$FPCTARGET- so the compiler would look for, for example the assembler, as i386-linux-as instead of just plain as.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: kc87654321 on July 04, 2012, 09:28:47 am
 ;D thinks ,i try. 8-)
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Diego on August 24, 2014, 05:46:54 pm
Hello, I'm having the same problem, follow the step by step of http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM.

I'm trying to build lazarus and I get the error: /home/mint/lazarus/packager/registration/lazaruspackageintf.pas(104) Error: Assembler arm-linuxas not found, switching to external assembling

Could anyone help me?
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Diego on August 24, 2014, 10:26:52 pm
Fix it, adding -XParm-linux- in lazarus, following Tools -> Configure Build Lazarus -> Options. The last dash (-) is very important, without it I believe the fpc concatenates the assembly (arm-linuxas), which should be arm-linux-as.

Now I am getting the below error, someone could explain why? I'm using 64bit linux.

Free Pascal Compiler version 2.6.4 [2014/08/24] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Note: Switching assembler to default source writing assembler
Target OS: Linux for x86-64
Compiling lazarus.pp
Compiling redirect_stderr.pas
Assembling redirect_stderr
/usr/local/bin/arm-linux-as_org: unrecognized option '--64'
redirect_stderr.pas(143) Error: Error while assembling exitcode 1
redirect_stderr.pas(143) Fatal: There were 2 errors compiling module, stopping
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Leledumbo on August 25, 2014, 10:09:38 am
Fix it, adding -XParm-linux- in lazarus, following Tools -> Configure Build Lazarus -> Options. The last dash (-) is very important, without it I believe the fpc concatenates the assembly (arm-linuxas), which should be arm-linux-as.
If you see my reply to kc87654321, you won't experience this.
Now I am getting the below error, someone could explain why? I'm using 64bit linux.

Free Pascal Compiler version 2.6.4 [2014/08/24] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Note: Switching assembler to default source writing assembler
Target OS: Linux for x86-64
Compiling lazarus.pp
Compiling redirect_stderr.pas
Assembling redirect_stderr
/usr/local/bin/arm-linux-as_org: unrecognized option '--64'
redirect_stderr.pas(143) Error: Error while assembling exitcode 1
redirect_stderr.pas(143) Fatal: There were 2 errors compiling module, stopping
Check your binutils. If it's already 64-bit, I don't think it accepts --64 parameter. Not sure though, better consult binutils documentation.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Diego on August 25, 2014, 01:18:14 pm
Hello Leledumbo, thanks for replying.

I have found no way to correct this error, so I installed a new linux 32bit in a VM, but after arriving in step "Configure Lazarus for cross Compile" tutorial http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM still get the error, but now with '--32'

Erro:
Free Pascal Compiler version 2.6.4 [2014/08/25] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Note: Switching assembler to default source writing assembler
Target OS: Linux for i386
Compiling lazarus.pp
Compiling redirect_stderr.pas
Assembling redirect_stderr
/usr/local/bin/arm-linux-as_org: unrecognized option '--32'

I believe that the problem is not on the platform. : /

The strange thing is that at no time do not add the option '--32' and do not know where and at what time this command is inserted.

Would you assist me?
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Leledumbo on August 25, 2014, 01:34:22 pm
Likewise, you're now on 32-bit platform. If your binutils is already 32-bit, it may not accept --32 parameter. Logically, you only need it to assemble/link FOR different architecture than the host.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Diego on August 25, 2014, 10:35:45 pm
I looked at the documentation (https://sourceware.org/binutils/docs/binutils/index.html) and found nothing related, just found this bug that speaks of the case: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54996

The biggest doubt is where it is being inserted option --32 or --64?  I did not insert option. I'm doing cross compile Linux (i386 or x86_64) for ARM, how to pass the correct option for arm?

I lowered my Beanutils of gnu ftp: http://ftp.gnu.org/gnu/binutils/ and configured beanutils following the steps of section "Install & Configure Binutils" of the tutorial "http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM"

Thanks again for help leledumbo!
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Leledumbo on August 26, 2014, 09:02:22 am
The biggest doubt is where it is being inserted option --32 or --64?  I did not insert option. I'm doing cross compile Linux (i386 or x86_64) for ARM, how to pass the correct option for arm?
The compiler passes that, the respective file is compiler/x86/agx86att.pas. So it's binutils problem. You might need to tailor certain options when building it. I got mine from official repository of my distro (which probably has the options enabled). Here (https://sourceware.org/binutils/docs/as/i386_002dOptions.html) is the respective documentation link for that option.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Diego on August 26, 2014, 11:57:51 am
Okay Leledumbo, I'll try to install the binutils repository of my distro, to see if it works.

Still got one doubt. Created a test.pas file with the content:

program test;
begin
  writeln('DATE ',{$i %DATE%});
  writeln('FPCTARGET ',{$i %FPCTARGET%});
  writeln('FPCTARGETCPU ',{$i %FPCTARGETCPU%});
  writeln('FPCTARGETOS ',{$i %FPCTARGETOS%});
  writeln('FPCVERSION ',{$i %FPCVERSION%});
end.

and executed:

$ fpc -Tlinux -Parm -XParm-linux- test.pas

The console showed the text below and generated all files to ARM platform with successfully:

Free Pascal Compiler version 2.6.4 [2014/08/24] for arm
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Linux for ARMEL
Compiling test.pas
Assembling test
Linking test
8 lines compiled, 0.4 sec

Is that really the problem is the beanutils or lazarus? Using the fpc command to compile the test.pas it works but when I try to "Configure Lazarus for cross Compile" generates errors.

I think the team lazarus should provide a version that is configured for this purpose.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Leledumbo on August 27, 2014, 11:02:56 am
Is that really the problem is the beanutils or lazarus? Using the fpc command to compile the test.pas it works but when I try to "Configure Lazarus for cross Compile" generates errors.
Your binutils works then. It's too weird if it works for test program above but not for program above, since the command line option would be similar (you can check yourself by watching make output).
Quote
I think the team lazarus should provide a version that is configured for this purpose.
Go look for a maintainer. There's none for arm-linux ATM.
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: marcov on August 27, 2014, 01:03:29 pm
There are many ARM targets.  There is no universal arm-linux. It all depends on device, and target CPU
Title: Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
Post by: Diego on August 27, 2014, 09:47:36 pm
I understand Marcov, really must be difficult to create a version of lazarus i386 or x86_64 with configuring cross compile for Arm preconfigured.

Leledumbo agree with you, it really is very strange. The worst that the entire configuration of fpc, fpc-src and beanutils is successful. The binary for ARM are created when executed by the terminal using only the fpc, but when starting configuration for Lazarus generate for binaries ARM, many mistakes happen.

According to my tests I believe that should be the file ~/.fpc.cfg that is not well configured for Lazarus. Mine is like this:

#INCLUDE /etc/fpc.cfg
#DEFINE DEMOTEST
#DEFINE DEMOTEST1
#DEFINE LAZARUS

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

-a
-Sd
-Xd
-Xs

-O-

#IFDEF CPUARM
-XP/home/user/lazarus/fpc/binutils/
-Xr/usr/lib/fpc/2.6.4/units/arm-linux/rtl/
-Xr/home/user/lazarus/fpc/libcross
-XR/home/user/lazarus/fpc/
-darm
-Tlinux
#ENDIF
TinyPortal © 2005-2018