<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-family: Verdana,Geneva,sans-serif'>
<p>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.<br /><br />As soon as I try to use the function "file_size" I get the following linker errors:<br /><br />Free Pascal Compiler version 2.6.2 [2013/03/17] for i386<br />Copyright (c) 1993-2012 by Florian Klaempfl and others<br />Target OS: Win32 for i386<br />Compiling test.pp<br />Compiling test_h.pas<br />Linking project1.exe<br />test.pp(9,1) Error: Undefined symbol: _open<br />test.pp(9,1) Error: Undefined symbol: _filesize<br />test.pp(9,1) Error: Undefined symbol: _close<br />test.pp(9,1) Fatal: There were 3 errors compiling module, stopping<br /><br />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.<br /><br />Any help appreciated.<br /><br />Regards, Darius<br /><br /><br /><br />marcov@stack.nl schreef op 21 apr '13:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<pre>In our previous episode, Vittorio Giovara said:</pre>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%">
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%">{$linklib gcc} What other libraries should I add? BTW, I'm compiling the C library with MinGW.</blockquote>
You need to instruct fpc to use gcc instead of default ld when you link c/pas code statically.</blockquote>
<pre>Fpc can't call gcc.</pre>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%">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.</blockquote>
<pre>FPC can pass extra flags to the linker. Just harvest the flags by compiling
a simple program with gcc
 
_______________________________________________
fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a>
</pre>
</blockquote>
<p> </p>
<br />
<div> </div>
</body></html>