[fpc-pascal] Linking C object against "Pascal runtime"

moichos at gmx.de moichos at gmx.de
Sat May 8 21:37:42 CEST 2010


Hi,

I have a C file which I want to link statically into my FreePascal application. The C code is mostly self-contained, except for a few simple calls to the C runtime, one of them being "_strlen".

Now "_strlen" is a simple enough function to rewrite it in Pascal, and so I did. However, FreePascal seems unable to recognize my strlen function in Pascal. It keeps reporting "Error: Undefined symbol: _strlen". My code looks like this, and "_strlen" is clearly present:

{$link cfile.o}

function _strlen(s: pansichar): integer; cdecl;
begin
  Result := 0;
  while s^ <> #0 do
  begin
    Inc(Result); Inc(s);
  end;
end;

Is it not possible to link C object files against an internal "Pascal runtime"? Or if it is, how do I make it happen?

Any solutions would be greatly appreciated!

Moichos




More information about the fpc-pascal mailing list