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

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


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;
  Result := 0;
  while s^ <> #0 do
    Inc(Result); Inc(s);

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!


More information about the fpc-pascal mailing list