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

Yury Sidorov jura at cp-lab.com
Wed Mar 15 12:54:17 CET 2017


On 3/14/2017 4:47 PM, Ladislav Karrach wrote:
>
>> Did you try this:
>>   function ippiThreshold(pSrcDst: PIpp8u; srcDstStep: int;
>>           roiSize: IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u;
>> thresholdGT: Ipp8u;
>>           valueGT: Ipp8u): IppStatus; external 'ippi.dll' name
>> 'ippiThreshold_LTValGTVal_8u_C1IR';
>> You should use
>> objdump -p ippi.dll
>> to get the names of the exported procedures/functions.
> Yes I know, this work: external 'ippi.dll' (I have added also "stdcall")
> But my question was regarding how to staticaly link provided libraries
> into my EXE (so I do not want distribute also all DLLs)
> Just like one can do it in C/C++

Yes, you can statically link a COFF library created by other compiler.

Use objdump as explained earlier to find out the name of ippiThreshold 
function in the static library. It may be prefixed with "_".

Then insert the proper name in the external declaration:

function ippiThreshold(pSrcDst: PIpp8u; srcDstStep: int; roiSize: 
IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u; thresholdGT: Ipp8u; 
valueGT: Ipp8u): IppStatus; external name '<proper_name>';

Also specify proper calling convention: cdecl or stdcall. But it does 
not affect linking if name is explicitly specified.

Yury.



More information about the fpc-devel mailing list