Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-06

shared library on arm-linux (raspberry pi)

10 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Fabio Luis Girardi

What's the current status of dynlibs unit for Linux ARM?

I'm doing a project and a shared library, both on a raspberry pi with FPC 2.6.4. I built the shared library successfully, but when I try build a empty program only with dynlibs unit on uses, the program won't compile. The output is:

~/ffcfilas/libcustomization.wizard $ fpc program1.fpr Free Pascal Compiler version 2.6.4 [2014/03/21] for arm Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Linux for ARMEL
Compiling program1.fpr
Assembling program1
Linking program1
/usr/bin/ld: warning: link.res contains output sections; did you forget -T? /usr/lib/fpc/2.6.4/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi':
(.text+0x88): undefined reference to `_fini'
/usr/lib/fpc/2.6.4/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi':
(.text+0x90): undefined reference to `_init'
program1.fpr(16) Error: Error while linking
program1.fpr(16) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: /usr/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compile

The program program1.fpr is:

program program1;
uses dynlibs;
procedure test;
begin
end;
begin
  test;
end.

My FPC come from
http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/fpc-2.6.4.arm-linux.tar

On a Linux 64, the program and the shared library compiles and works fine.

So, programs and shared libraries works fine on RPi or I'm doing something wrong?

The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email

Fabio Luis Girardi
to Fabio Luis Girardi

I did more tests. If I try build a empty program linked with libc, this program cause a linker failure as mentioned on previous message.

program program1;
{$LINKLIB c}
begin
end.

Someone can say if this is a problem with my raspbian image or a problem with my FPC installation?

2014-06-25 23:52 GMT-03:00 Fabio Luis Girardi :

Show quoted text 62 lines
What's the current status of dynlibs unit for Linux ARM? I'm doing a project and a shared library, both on a raspberry pi with FPC 2.6.4. I built the shared library successfully, but when I try build a empty program only with dynlibs unit on uses, the program won't compile. The output is: ~/ffcfilas/libcustomization.wizard $ fpc program1.fpr Free Pascal Compiler version 2.6.4 [2014/03/21] for arm Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Linux for ARMEL Compiling program1.fpr Assembling program1 Linking program1 /usr/bin/ld: warning: link.res contains output sections; did you forget -T? /usr/lib/fpc/2.6.4/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi': (.text+0x88): undefined reference to `_fini' /usr/lib/fpc/2.6.4/units/arm-linux/rtl/cprt0.o: In function `_haltproc_eabi': (.text+0x90): undefined reference to `_init' program1.fpr(16) Error: Error while linking program1.fpr(16) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /usr/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compile The program program1.fpr is: program program1; uses dynlibs; procedure test; begin end; begin test; end. My FPC come from http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/fpc-2.6.4.arm-linux.tar On a Linux 64, the program and the shared library compiles and works fine. So, programs and shared libraries works fine on RPi or I'm doing something wrong? -- The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com
The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email

Marco van de Voort
to Fabio Luis Girardi

In our previous episode, Fabio Luis Girardi said:

Someone can say if this is a problem with my raspbian image or a problem with my FPC installation?

Did you use the raspbian provided (and patched!) FPC or did you build your own?

Stock 2.6.4 does NOT run armhf systems, Raspbian patched theirs.

Reply by email

Fabio Luis Girardi
to Marco van de Voort

No, I installed FPC on Rpi using this file:

http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/fpc-2.6.4.arm-linux.tar

Using the FPC 2.6.4, I tried build a fresh FPC 2.7.1 on Rpi, but I found the same error.

So, I have to go back and install FPC from Raspibian repositories...

2014-06-26 10:57 GMT-03:00 Marco van de Voort :

Show quoted text 9 lines
In our previous episode, Fabio Luis Girardi said: > Someone can say if this is a problem with my raspbian image or a problem > with my FPC installation? Did you use the raspbian provided (and patched!) FPC or did you build your own? Stock 2.6.4 does NOT run armhf systems, Raspbian patched theirs.
The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email

Fabio Luis Girardi
to Fabio Luis Girardi

Hi!

I did more tests, with a clean raspbian image, using fpc that comes with raspbian repositories. Now I can compile a program and the shared library, but I can't load my shared library on my program, but my program can load and use a shared library built in C. Maybe a FPC bug?? No, I installed FPC on Rpi using this file:

http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/fpc-2.6.4.arm-linux.tar

Using the FPC 2.6.4, I tried build a fresh FPC 2.7.1 on Rpi, but I found the same error.

So, I have to go back and install FPC from Raspibian repositories...

2014-06-26 10:57 GMT-03:00 Marco van de Voort :

Show quoted text 9 lines
In our previous episode, Fabio Luis Girardi said: > Someone can say if this is a problem with my raspbian image or a problem > with my FPC installation? Did you use the raspbian provided (and patched!) FPC or did you build your own? Stock 2.6.4 does NOT run armhf systems, Raspbian patched theirs.
The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email

Fabio Luis Girardi
to Fabio Luis Girardi

The output of "readelf -a" with libraries built in C and FPC...

The command line used to build the library in fpc is:

fpc ulib.pas
fpc -Cg -Xc -CD -CX library1.fpr

I guess that FPC forgot something...

2014-06-26 22:45 GMT-03:00 Fabio Luis Girardi :

Show quoted text 42 lines
Hi! I did more tests, with a clean raspbian image, using fpc that comes with raspbian repositories. Now I can compile a program and the shared library, but I can't load my shared library on my program, but my program can load and use a shared library built in C. Maybe a FPC bug?? No, I installed FPC on Rpi using this file: http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/fpc-2.6.4.arm-linux.tar Using the FPC 2.6.4, I tried build a fresh FPC 2.7.1 on Rpi, but I found the same error. So, I have to go back and install FPC from Raspibian repositories... 2014-06-26 10:57 GMT-03:00 Marco van de Voort : > In our previous episode, Fabio Luis Girardi said: > > Someone can say if this is a problem with my raspbian image or a problem > > with my FPC installation? > > Did you use the raspbian provided (and patched!) FPC or did you build your > own? > > Stock 2.6.4 does NOT run armhf systems, Raspbian patched theirs. > -- The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com
The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email

Jonas Maebe
to Fabio Luis Girardi
Fabio Luis Girardi wrote 6 lines
The output of "readelf -a" with libraries built in C and FPC... The command line used to build the library in fpc is: fpc ulib.pas fpc -Cg -Xc -CD -CX library1.fpr

FPC does not support PIC code for ARM in 2.6.x. Additionally, if you want PIC, then just compiling the library file with -Cg is useless, because all code inside the library must be compiled as PIC for it to have any effect (including the RTL). It's this lack of PIC that causes all the R_ARM_RELATIVE dynamic relocations. Most Linux platforms also support libraries without PIC though.

And as the FPC help says, -CD is unsupported (nor needed; it is related to the as of yet unimplemented Delphi-style dynamic packages support).

If you want to debug shared library loading issues, a good starting point is setting the environment variables LD_VERBOSE=1 and LD_DEBUG=all before running the program that loads the library.

Jonas

Reply by email

Fabio Luis Girardi
to Jonas Maebe
"Jonas Maebe" wrote
And as the FPC help says, -CD is unsupported (nor needed; it is related

to the as of yet unimplemented Delphi-style dynamic packages support).

I'm testing any option that appears to be useful to build a shared library. Even If the help says that is unsupported. I'm desperate :)

If you want to debug shared library loading issues, a good starting point

is setting the environment variables LD_VERBOSE=1 and LD_DEBUG=all before running the program that loads the library.

I'll try this.

Reply by email

Jonas Maebe
to Fabio Luis Girardi
Fabio Luis Girardi wrote
I'm testing any option that appears to be useful to build a shared library. Even If the help says that is unsupported. I'm desperate :)

Unsupported options are much more likely to break things than fix things.

Jonas

Reply by email

Fabio Luis Girardi
to Jonas Maebe

Hi all!!

First (tests made on ARMHF): I did tests with latest FPC, built from trunk. The trouble persists. A simple program can't load a simple shared library, both built in FPC, but my program built in FPC can load a shared library built in gcc.

As Marco said, stock fpc 2.6.4 don't works on armhf. So I downgrade my linux install to a ARMEL distro (raspbian from 2013-05) and everything works very well.

So, comparing the results, this can be a bug in the shared library mechanism of FPC on ARMHF?

2014-06-28 12:29 GMT-03:00 Jonas Maebe :

Show quoted text 14 lines
On 28/06/14 16:48, Fabio Luis Girardi wrote: > I'm testing any option that appears to be useful to build a shared > library. Even If the help says that is unsupported. I'm desperate :) > Unsupported options are much more likely to break things than fix things. Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email