[fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

Yury Sidorov jura at cp-lab.com
Thu Mar 16 11:28:31 CET 2017


On 3/16/2017 12:01 PM, LacaK wrote:
> Then I get:
>   test_IPP.lpr(17,1) Error: undefined reference to `ippGetLibVersion'
> (I have tried also: _ippGetLibVersion, _ippGetLibVersion at 0 ...)

I've downloaded the IPP libs and did some tests to make sure that static 
linking is possible.

The working declaration is:

{$L ippcoremt.lib}
function ippGetLibVersion: PIppLibraryVersion; cdecl; external name 
'ippGetLibVersion at 0';

You need to use the external linker via the -Xe option, since internal 
linker does not support static libraries. Only single object files can 
be linked.

ippGetLibVersion at 0 - is the C++ mangled name used by MS VC++. FPC 
supports then "cppdecl" calling convention, but only for the GCC 
compiler, which uses different name mangling algorithm. So you need to 
use cdecl and manually specify the name. Function names can be found 
using "objdump -t ippcoremt.lib". You should specify the name without 
the "_" prefix. It is added automatically when cdecl is used.

Yury.



More information about the fpc-devel mailing list