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

LacaK lacak at zoznam.sk
Tue Mar 14 16:26:25 CET 2017


Dňa 14.3.2017 o 15:57 silvioprog napísal(a):
> On Tue, Mar 14, 2017 at 9:30 AM, LacaK <lacak at zoznam.sk 
> <mailto:lacak at zoznam.sk>> wrote:
>
>     Hi,
>
>     I have C/C++ librarby (".lib" for Windows and ".a" for Linux) from
>     Intel IPP package (they distribute ".lib" and also ".dll" for
>     Windows and ".a" for Linux)
>
>     Can I link in FPC (on Windows) at compile time to this ".lib"
>     versions ? Or only possible way is link at runtime using ".dll"
>     (and distribute DLLs with my EXE)?
>     (I guess, that FPC can not link to libraries not created in FPC
>     itself. So format of supplied ".lib" is not compatible with what
>     FPC expects)
>
>     I am trying do something like:
>     {$linklib libippi}
>     function ippiThreshold_LTValGTVal_8u_C1IR(pSrcDst: PIpp8u;
>     srcDstStep: int;
>            roiSize: IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u;
>     thresholdGT: Ipp8u;
>            valueGT: Ipp8u): IppStatus; external; // 'ippi.dll';
>
>     (In Project Options I have path to libippi.a in -Fl)
>
>     But I get error: test_IPP.lpr(24,1) Error: Undefined symbol:
>     IPP_IPPITHRESHOLD_LTVALGTVAL_8U_C1IR$PIPP8U$LONGINT$IPPISIZE$BYTE$BYTE$BYTE$BYTE$$IPPSTATUS
>
>
> test 1: are you on win32? If so, did you try using prefix "_"? eg:
>
> function _ippiThreshold_LTValGTVal_8u_C1IR(pSrcDst: PIpp8u; 
> srcDstStep: int;
>        roiSize: IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u; 
> thresholdGT: Ipp8u;
>        valueGT: Ipp8u): IppStatus; external;
>
here I get (without {$linklib}):
   Error: Undefined symbol: 
IPP__IPPITHRESHOLD_LTVAL_8U_C1IR$PIPP8U$LONGINT$IPPISIZE$BYTE$BYTE$$IPPSTATUS

> test 2: put the library implementation below function declaration, eg:
>
> function _ippiThreshold_LTValGTVal_8u_C1IR(pSrcDst: PIpp8u; 
> srcDstStep: int;
>        roiSize: IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u; 
> thresholdGT: Ipp8u;
>        valueGT: Ipp8u): IppStatus; external;
> {$linklib libippi}
here I get:
   Error: Undefined symbol: 
IPP__IPPITHRESHOLD_LTVAL_8U_C1IR$PIPP8U$LONGINT$IPPISIZE$BYTE$BYTE$$IPPSTATUS
(same error if I add: {$linklib ippi} or {$linklib libippi} ... ippi.lib 
and libippi.a are in directory where -Fl points)

>
> fix 1: check which convention your library was compiled,
I think it is stdcall and I have this calling convention there (extdecl 
is macro: {$DEFINE extdecl:=stdcall}  ):
   function _ippiThreshold_LTVal_8u_C1IR(pSrcDst: PIpp8u;srcDstStep: 
int;  roiSize: IppiSize; threshold: Ipp8u; value: Ipp8u): IppStatus;
    extdecl; external;

-Laco.



More information about the fpc-devel mailing list