shared library on arm-linux (raspberry pi)

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

shared library on arm-linux (raspberry pi)

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:

pi@raspberrypi ~/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.


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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: shared library on arm-linux (raspberry pi)

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 <[hidden email]>:
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:

pi@raspberrypi ~/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.


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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: shared library on arm-linux (raspberry pi)

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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: shared library on arm-linux (raspberry pi)

Fabio Luis Girardi
No, I installed FPC on Rpi using this file: 


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 <[hidden email]>:
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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: shared library on arm-linux (raspberry pi)

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: 


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 <[hidden email]>:
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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: shared library on arm-linux (raspberry pi)

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 <[hidden email]>:

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: 


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 <[hidden email]>:
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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

outlib_Built_in_C (18K) Download Attachment
outlib_Built_in_FPC (246K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: shared library on arm-linux (raspberry pi)

Jonas Maebe-2
On 27/06/14 16:24, Fabio Luis Girardi wrote:
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: shared library on arm-linux (raspberry pi)

Fabio Luis Girardi


Em 28/06/2014 09:13, "Jonas Maebe" <[hidden email]> escreveu:
>
> 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.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: shared library on arm-linux (raspberry pi)

Jonas Maebe-2
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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: shared library on arm-linux (raspberry pi)

Fabio Luis Girardi
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 <[hidden email]>:
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  -  [hidden email]
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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal