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.
