P. George wrote::
i'm using gpc (on the commandline, not in mw) in os x. i need to call a carbon library function.
the following line doesn't work:
{$L /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon}
when i try to compile with:
gpc testcarb.pas -o testcarb
... i get:
testcarb.pas:6: error: file `/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon' must be compiled
not sure what that means or what i can do about it.
Download the Mac OS X Pascal interfaces http://www.microbizz.nl/GPCInterfacesC2.tar.gz and include GPCMacOSAll.pas (or separate smaller units) with the USES clause. Now, link to the Carbon framework with:
gpc -s -o testcarb testcarb.pas --automake -Wl,-framework,Carbon --unit-path=/Developer/Pascal/GPCPInterfaces -I/Developer/Pascal/GPCPInterfaces
See the example makefile in the "tools" folder included with the GPCPInterfaces.
Frank Heckenbach wrote:
Not sure about the circumstances, but generally: Don't put paths in the source. I.e., use `{$L Carbon}' if that's the name of the library (i.e., `libCarbon.a' or so, depending on your system's naming convention which I don't know), and use options such as `-L /System/Library/Frameworks/Carbon.framework/Versions/A'.
Interestingly, $L doesn't recognize /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon, although it is a Mach-O file and a dynamic library. So, this must be the reason why you get the "must be compiled" message ($L also accepts source files). I don't know (haven't checked) the naming conventions of the $L directive. Does it look at the file name suffix or does it check the binary (Mach-O) file type ?
Besides (hopefully) avoiding this problem, it will help others compile this file who may have set up their directories differently.
On Mac OS X, using the "frameworks" convention avoids the directory setup problem (as the dynamic libraries included with "frameworks" are in a fixed and known places for each version of the OS on all installations).
Regards,
Adriaan van Os