[fpc-pascal]Getting pascal code to link with C code

md md at realmwireless.com
Thu Nov 9 07:22:40 CET 2000


This problem is under linux OS.

Maybe someone has an insight on a problem that I am having
trying to get a shared library created by Free Pascal
to be callable in code by GNU C.

If libraries do not work under Free Pascal, then I would like to link 
in the object file that is created by the PPC386 compiler.

I am using FPC1.0.2.  It indicates in the help text of the compiler that
the -CD switch is not supported.  The -CS option is not recognized by
PPC386.  

Imagine compiling the following test.pp file:

library test;

uses funcunit ;  (all functions inside unit are cdecl declarations)

exports

testfunc1, testfunc2 ;

end.

*********************

Now compile the unit into a library: ppc386 -CD -g -P -Sd -Op2  test.pp

This creates a libtest.so file that is statically linked.  

I do not believe it is a library with position independent code.

*********************

Now, I could use gcc -ltest to link this into a GNU C compiled program,
but upon calling the external function
in the library, I get an exception thrown and the process is ended.

Any ideas on getting pascal code linked into C programs?  Either using
.so shared library or linking .o file directly.  

Thanks,

Mark Diener




More information about the fpc-pascal mailing list