[fpc-pascal] Linking Problems while cross compiling for arm

Hartmut Eilers hartmut at eilers.net
Mon Dec 7 10:46:42 CET 2009


Hallo List,

I try to crosscompile one of my projects to the arm based
USB9263 from Calao Systems
(http://www.calao-systems.com/articles.php?lng=en&pg=5932)

I get the following linking error:

ubuntu at kubuntu904:~/OpenLabTools/DeviceServer$
/usr/local/bin/ppcrossarm -CfFPA  -dUSB92 -CaARMEB -CpARMV5 -darm
-dFPC_ARMEL  -gl -Fu../webserver -Fu../PhysMach
-Fu../divLibs/pwu-1.6.0.2-src/main/
-FL/usr/xtools/arm-unknown-linux-uclibc/arm-unknown-linux-uclibc/lib/ld-uClibc.so.0
-Fl/usr/local/xtools/arm-unknown-linux-uclibc/arm-unknown-linux-uclibc/lib/
-XParm-unknown-linux-uclibc- -Xd
-Xr/usr/local/xtools/arm-unknown-linux-uclibc/ DeviceServer.pas
Free Pascal Compiler version 2.4.0rc1 [2009/12/07] for arm
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARM
Compiling DeviceServer.pas
DeviceServer.pas(538,10) Warning: Function result does not seem to be set
Assembling deviceserver
Linking DeviceServer
/usr/local/lib/fpc/2.4.0/units/arm-linux/rtl/cprt0.o: In function `_start':
(.text+0x4c): undefined reference to `__libc_start_main'
/usr/local/lib/fpc/2.4.0/units/arm-linux/rtl/cprt0.o: In function
`_haltproc_eabi':
(.text+0x88): undefined reference to `_fini'
/usr/local/lib/fpc/2.4.0/units/arm-linux/rtl/cprt0.o: In function
`_haltproc_eabi':
(.text+0x90): undefined reference to `_init'
DeviceServer.pas(609,2) Error: Error while linking
DeviceServer.pas(609,2) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

I have built my own crosscompiler with fpc 2.2.2. Here are the steps I did:

+ download the toolchain from
http://free-electrons.com/labs/tools/arm-unknown-linux-uclibc-gcc-4.3.2.tar.bz2
and uncompress it as root in /.
Then, add the cross-compiler directory to the PATH
export PATH=/usr/local/xtools/arm­unknown­linux­-uclibcgnueabi/bin:$PATH

+ download a recent version of fpc
svn checkout http://svn.freepascal.org/svn/fpc/tags/release_2_4_0_rc1 ./fpc240
+ compile the compiler
patch sdl mixer to avoid error, so no sdl lib is included
cd ./fpc240
vi packages/sdl/src/sdl_mixer.pas

 change lines starting at 450

       {$IFNDEF DARWIN}
       5 : ( mp3 : PSMPEG );
       {$ENDIF}

 with these lines, the sdl lib is removed !

       {$IFNDEF DARWIN}
       {$IFNDEF no_smpeg}
       5 : ( mp3 : PSMPEG );
       {$ENDIF}
       {$ENDIF}


make clean
make crosszipinstall CPU_TARGET=arm CROSSOPT='-CfFPA -dUSB92 -darm
-dno_smpeg -dFPC_ARMEL -O- -gl'
CROSSBINDIR=/usr/local/xtools/arm-unknown-linux-uclibc/bin/
BINUTILSPREFIX=arm-unknown-linux-uclibc-

+ Installation of the binaries
cd /usr/local/
tar -xzvf /home/ubuntu/fpc240/fpc-2.4.0rc1.arm-linux.tar.gz
cd /usr/local/bin
ln -s /usr/local/lib/fpc/2.4.0/ppcrossarm ppcrossarm

Compiling programs:

/usr/local/bin/ppcrossarm -CfFPA  -dUSB92 -CaARMEB -CpARMV5 -darm
-dFPC_ARMEL   -gl -Fu../webserver -Fu../PhysMach
-Fu../divLibs/pwu-1.6.0.2-src/main/
-FL/usr/xtools/arm-unknown-linux-uclibc/arm-unknown-linux-uclibc/lib/ld-uClibc.so.0
-Fl/usr/local/xtools/arm-unknown-linux-uclibc/arm-unknown-linux-uclibc/lib/
-XParm-unknown-linux-uclibc- -Xd
-Xr/usr/local/xtools/arm-unknown-linux-uclibc/ DeviceServer.pas

Can anybody give me hints what to do or check what I did wrong.
Especially the steps building the crosscompiler.
I also tried to use the -k ... with sys-root but the the linker
complains that he couldn't find the dl lib. I guess I have something
wrong with the pathes of the -F* parameters.

ubuntu at kubuntu904:~/OpenLabTools/DeviceServer$
/usr/local/bin/ppcrossarm -CfFPA  -dUSB92 -CaARMEB -CpARMV5 -darm
-dFPC_ARMEL  -gl -Fu../webserver -Fu../PhysMach
-Fu../divLibs/pwu-1.6.0.2-src/main/
-FL/usr/xtools/arm-unknown-linux-uclibc/arm-unknown-linux-uclibc/lib/ld-uClibc.so.0
-Fl/lib/ -XParm-unknown-linux-uclibc- -Xd
-Xr/usr/local/xtools/arm-unknown-linux-uclibc/ -Fi
/usr/local/xtools/arm-unknown-linux-uclibc/arm-unknown-linux-uclibc/include/c++/4.3.2/
-k"--sysroot=/usr/local/xtools/arm-unknown-linux-uclibc/arm-unknown-linux-uclibc/include/c++/4.3.2/sys-root/"
DeviceServer.pas
Warning: Only one source file supported, changing source file to
compile from "/usr/local/xtools/arm-unknown-linux-uclibc/arm-unknown-linux-uclibc/include/c++/4.3.2/"
into "DeviceServer.pas"
Free Pascal Compiler version 2.4.0rc1 [2009/12/07] for arm
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARM
Compiling DeviceServer.pas
DeviceServer.pas(538,10) Warning: Function result does not seem to be set
Assembling deviceserver
Linking DeviceServer
/usr/local/xtools/arm-unknown-linux-uclibc/bin/arm-unknown-linux-uclibc-ld:
cannot find -ldl
DeviceServer.pas(609,2) Error: Error while linking
DeviceServer.pas(609,2) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

Thanks for your help
regards
Hartmut



More information about the fpc-pascal mailing list