[fpc-pascal] trying to use C code in .pas on WIN32

Sven Barth pascaldragon at googlemail.com
Thu Jan 31 07:34:45 CET 2019


Am 30.01.2019 um 23:14 schrieb conlin664 via fpc-pascal:
> ok. I backed up to a simple version.
> how I declare the C routine must be the problem,
> with nothing,
>      procedure HelloC; cdecl; external;
>
> I think it's trying to static link it, and gets an
>     pcode.pas(19,1) Error: Undefined symbol: _HelloC
>
>
>   with anything else
>
>     procedure HelloC; cdecl; external 'HelloC';
>
> it links, but dynamically and then the routine is never found.
With merely "external" the compiler uses the C variant of the identifier 
for the platform which on Win32 contains a "_" at the start (for Win64 
for example there is none).
"external <NAME>" is used to tell the compiler to look for the C 
identifier ("_HelloC" on Win32, "HelloC" on Win64) inside the library 
"HelloC.dll".
To look for "HelloC" in a statically linked object file or library you 
need to use "external name <NAME>".

> This is on an evil windows machine
Windows is one of FPC's main targets, we can do without such "expletives".

Regards,
Sven



More information about the fpc-pascal mailing list