[fpc-pascal] Linking using "external" on Mac OS X

Michalis Kamburelis michalis.kambi at gmail.com
Wed Mar 28 21:46:54 CEST 2007


Hi

I experience problems linking using "external" keyword on Mac OS X.  
Program with declaration like

procedure glVertex3f(x, y, z: Single); cdecl; external 'GL' name  
'glVertex3f';

fails to compile with

$ fpc external_decl.pas
/usr/bin/ld: Undefined symbols:
_glVertex3f
Error: Error while linking

(note the strange underscore at the beginning of reported  
"_glVertex3f").

Similar problems seem to arise with gtkglext unit under Mac OS X.  
What's interesting is that the problems are gone if I add {$linklib  
GL} (in case of glVertex3f example). So it seems to me that  under  
Mac OS X
1. the name of the library specified after "external" keyword is ignored
2. I have to link to libraries using {$linklib xxx} method

This is what gtk2 unit uses, and it links OK with GTK library from  
fink. Also construct like
function sem_post(__sem:Pointer): LongInt; cdecl; external 'c' name  
'sem_post';
works OK in FPC's RTL, I guess that somewhere in Darwin RTL there's  
included {$linklib c}.

Am I right ? Is this a known limitation of FPC for Mac OS X, or  
should I submit to bugtracker ?

I'm attaching the small testcase.

Michalis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: external_decl.pas
Type: application/octet-stream
Size: 529 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20070328/01ebf296/attachment.obj>


More information about the fpc-pascal mailing list