[fpc-pascal] Statically link library

Darius Blaszyk dhkblaszyk at zeelandnet.nl
Sun Apr 21 16:38:42 CEST 2013


 

I have prepared a minimal example of the linking problems I get.
Just unzip, create a "build" dir and run cmake. I'm using gcc 4.6.2.

As
soon as I try to use the function "file_size" I get the following linker
errors:

Free Pascal Compiler version 2.6.2 [2013/03/17] for
i386
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS:
Win32 for i386
Compiling test.pp
Compiling test_h.pas
Linking
project1.exe
test.pp(9,1) Error: Undefined symbol: _open
test.pp(9,1)
Error: Undefined symbol: _filesize
test.pp(9,1) Error: Undefined symbol:
_close
test.pp(9,1) Fatal: There were 3 errors compiling module,
stopping

It really seems I need to add an additional library to the
pascal source or that the linker cannot find some included symbols in
the also attached libmsvcrt.a.

Any help appreciated.

Regards,
Darius

marcov at stack.nl schreef op 21 apr '13: 

> In our previous
episode, Vittorio Giovara said:
> 
>>> {$linklib gcc} What other
libraries should I add? BTW, I'm compiling the C library with MinGW.
>>
You need to instruct fpc to use gcc instead of default ld when you link
c/pas code statically.
> 
> Fpc can't call gcc.
> 
>> This is because
gcc adds many linker flags that are automatically set when you link
something but are not set when you call ld directly.
> 
> FPC can pass
extra flags to the linker. Just harvest the flags by compiling
> a
simple program with gcc
> 
>
_______________________________________________
> fpc-pascal maillist -
fpc-pascal at lists.freepascal.org
>
http://lists.freepascal.org/mailman/listinfo/fpc-pascal [1]




Links:
------
[1]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130421/057e9de5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fpc_C.zip
Type: application/zip
Size: 36311 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130421/057e9de5/attachment.zip>


More information about the fpc-pascal mailing list