[fpc-pascal] CThreads problem when cross-compiling to ARM/RPi.

Bruce Tulloch pascal at causal.com
Thu May 23 14:10:07 CEST 2013


Starting with a simple test program arm-test.pas:

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

I can cross-compile:

Free Pascal Compiler version 2.7.1 [2013/05/20] for arm
Copyright (c) 1993-2013 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling arm-test.pas
Assembling test
Linking arm-test
8 lines compiled, 0.1 sec

successfully producing this:

arm-test: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically
linked, for GNU/Linux 2.0.0, stripped

which when executed produces:

DATE 2013/05/23
FPCTARGET arm
FPCTARGETCPU arm
FPCTARGETOS Linux
FPCVERSION 2.7.1

All good, the ARM cross-compiler is working.

However, if I simply add this uses clause:

uses
  cthreads;

the program compiles fine but fails when linking:

Linking arm-test-threads
/usr/local/lib/fpc/2.7.1/
units/arm-linux/rtl/cthreads.o: In function
`CTHREADS_$$_LOADPTHREADS$$BOOLEAN':
cthreads.pp:(.text.n_cthreads_$$_loadpthreads$$boolean+0xc): warning: Using
'dlopen' in statically linked applications requires at runtime the shared
libraries from the glibc version used for linking
/usr/local/opt/chroot/raspbian/rootfs/usr/lib/arm-linux-gnueabihf//libdl.a(dlopen.o):
In function `dlopen':
(.text+0xc): undefined reference to `__dlopen'
/usr/local/opt/chroot/raspbian/rootfs/usr/lib/arm-linux-gnueabihf//libdl.a(dlclose.o):
In function `dlclose':
(.text+0x0): undefined reference to `__dlclose'
/usr/local/opt/chroot/raspbian/rootfs/usr/lib/arm-linux-gnueabihf//libdl.a(dlsym.o):
In function `dlsym':
(.text+0xc): undefined reference to `__dlsym'
/usr/local/opt/chroot/raspbian/rootfs/usr/lib/arm-linux-gnueabihf//libdl.a(dladdr.o):
In function `dladdr':
(.text+0x0): undefined reference to `__dladdr'
An error occurred while linking arm-test-threads

When compiling the same code native (x86_64) or cross compiled to Linux
i386, this does not happen (i.e the program links and executes fine). The
ARM linux system against which I'm linking is raspbian for RPi.

The relevant compiler configuration is:

#IFDEF CPUARM
-Xd
-k--sysroot=/usr/local/opt/chroot/raspbian/rootfs
-Fl/usr/local/opt/chroot/raspbian/rootfs/lib/arm-linux-gnueabihf
-Fl/usr/local/opt/chroot/raspbian/rootfs/usr/lib/arm-linux-gnueabihf
-FD/usr/local/opt/binutils/bin
-XP$FPCTARGET-
#ENDIF

What am I doing wrong?

Thanks, Bruce.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130523/dab5abb7/attachment.html>


More information about the fpc-pascal mailing list