Sign in Join

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

Mailing lists / fpc-devel / 2004-01

Report in manual inconsitencies about linking libraries, and questions.

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Javier Ros Ganuza

Note: al the coments aplies to linux (vesions 1.06 and 1.0.10)

Manual page: 1.0.6

−CS Create static library.

Manual page: 1.0.10

Not present in my system

prog.pdf in both versions:

Compiling libraries
Once you have your (adapted) code, with exported and other functions, you can compile your unit, and tell the compiler to make it into a library. The compiler will simply compile your unit, and perform the necessary steps to transform it into a static or shared (dynamic) library. You can do this as follows, for a dynamic library:

ppc386 -CD myunit

On UNIX systems, such as LINUX, this will leave you with a file libmyunit.so. On WINDOWS and OS/2, this will leave you with myunit.dll. An easier way to create shared libraries is to use the library keyword. For more information on creating shared libraries, chapter 11, page 93. If you want a static library, you can do

ppc386 -CS myunit

This will leave you with libmyunit.a and a file myunit.ppu. The myunit.ppu is the unit file needed by the Free Pascal compiler.

Behaviour in both versions

[jros kernel]$ ppc386 -CS the_unit.pp
Error: Illegal parameter: -CS
[jros kernel]$ ppc386 -CS the_dynamic_library.pp
Error: Illegal parameter: -CS
[jros kernel]$

-CD Behavior in both versions:

It is accepted, but the result is the same as if option not used

The comand line documentation in both versions:

[jros kernel]$ ppc386
Free Pascal Compiler version 1.0.10 [2003/06/26] for i386 Copyright (c) 1993-2003 by Florian Klaempfl
....

[jros kernel]$ ppc386
Free Pascal Compiler version 1.0.6 [2002/05/23] for i386 Copyright (c) 1993-2002 by Florian Klaempfl

...

Inline (ppc386) help in both versions:
....
-C<x> code generation options:
-CD create also dynamic library (not supported)

It does not apear -CS

The questions:

I'm able to link, the previous program with a ppc386 generated dynamic library. It works!

I'm able to link static, making a static library using the object files asociated to the units, generated in the dinamic library generating procces, and
/usr/lib/fpc/1.0.10/units/linux/rtl/dllprt0.o
/usr/lib/fpc/1.0.10/units/linux/rtl/syslinux.o

It works, werther I use directly the object files or I package them in a lib*.a library usin ar and ranlib

But in order to have a working link form C to the static lib I need:

---
extern void FPC_INITIALIZEUNITS (void);

int
main (int argc, char *argv[])
{
FPC_INITIALIZEUNITS();
...
---

Has been this trik already cicumvented?.

Is this a correct procedure?
From the analysis presented I supouse that free-pascal does not suport command line static linking.

Will be added this feature in the future?, will the above trik be removed?

A suggestion: Could be the documentation made coherent with this.

Coul be added the trick to make a static library and to link from a main C source to be added in=20

prog.pdf->linking Isues->Making Libraries->Compiling Libraries

Thanks

Javier

P.D.: I've developed and autotools(autoconf automake) toolchain with the example and the different casuistics. May somebody is interested. I've always wondered how to make freepascal work with autotools, may it can be included in the contributed code as an example on using that tools. I'm not an autotools expert but it works nicely.

Michael Van Canneyt
to Javier Ros Ganuza
Javier Ros Ganuza wrote 14 lines
But in order to have a working link form C to the static lib I need: --- extern void FPC_INITIALIZEUNITS (void); int main (int argc, char *argv[]) { FPC_INITIALIZEUNITS(); ... --- Has been this trik already cicumvented?.

No.

Is this a correct procedure?

Yes.

Show quoted text 5 lines
>From the analysis presented I supouse that free-pascal does not suport command line static linking. Will be added this feature in the future?, will the above trik be removed?

Yes.

A suggestion: Could be the documentation made coherent with this.

I will do so.

Show quoted text 5 lines
Coul be added the trick to make a static library and to link from a main C source to be added in prog.pdf->linking Isues->Making Libraries->Compiling Libraries

I will add this.

Show quoted text 10 lines
Thanks Javier P.D.: I've developed and autotools(autoconf automake) toolchain with the example and the different casuistics. May somebody is interested. I've always wondered how to make freepascal work with autotools, may it can be included in the contributed code as an example on using that tools. I'm not an autotools expert but it works nicely.

You can send it to me, maybe we can include it at least with FPC.

Michael.