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

silvioprog silvioprog at gmail.com
Tue Mar 14 16:45:31 CET 2017


On Tue, Mar 14, 2017 at 12:39 PM, silvioprog <silvioprog at gmail.com> wrote:

> On Tue, Mar 14, 2017 at 12:26 PM, LacaK <lacak at zoznam.sk> wrote:
>
>> Dňa 14.3.2017 o 15:57 silvioprog napísal(a):
>
> [...]
>
>> here I get (without {$linklib}):
>>   Error: Undefined symbol: IPP__IPPITHRESHOLD_LTVAL_8U_C1
>> IR$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_C1
>> IR$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;
>
>
> Awesome. Now we need to check how libippi had exported its symbols. :-)
> For example, to check the symbols from the libfoo.a sent in my previous
> message:
>
> $ objdump -t libfoo.a
> In archive libfoo.a:
>
> libfoo.o:     file format pe-i386
>
> SYMBOL TABLE:
> [  0](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x00000000 foo.c
> File
> *[  2](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 1) 0x00000000 _bar*
> AUX tagndx 0 ttlsiz 0x0 lnnos 0 next 0
> [  4](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .text
> AUX scnlen 0xa nreloc 1 nlnno 0
> [  6](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .data
> AUX scnlen 0x0 nreloc 0 nlnno 0
> [  8](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .bss
> AUX scnlen 0x0 nreloc 0 nlnno 0
> [ 10](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .rdata
> AUX scnlen 0x4 nreloc 0 nlnno 0
> [ 12](sec  5)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .rdata$zzz
> AUX scnlen 0x2a nreloc 0 nlnno 0
> [ 14](sec  6)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .eh_frame
> AUX scnlen 0x38 nreloc 1 nlnno 0
>
> Notice the _bar, now you need to check if libippi exported it as
> ippithreshold_ltvalgtval_8u_c1ir, _ippithreshold_ltvalgtval_8u_c1ir or
> ipp__ippithreshold_ltval_8u_c1ir. :-)
>

I forgot a question, could you send your ippi .a files for us? If so, I can
try a test here. :-)

-- 
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20170314/43be5798/attachment.html>


More information about the fpc-devel mailing list