Carbon interface FAQ

From Free Pascal wiki
Jump to: navigation, search
Logo OSX.png

This article applies to macOS only.

See also: Multiplatform Programming Guide

Apple iOS new.svg

This article applies to iOS only.

See also: Multiplatform Programming Guide

English (en) 日本語 (ja)

This is a list of frequently asked questions and problems about Carbon interace.

What's the state of Carbon interface?

The Carbon interface is not yet completed but is under permanent development to reach state of stable interfaces. You can find out current status at Roadmap#Status of features on each widgetset and Roadmap#Status of components on each widgetset. You should also look at Carbon interface internals#Compatibility issues.

What's the state of Lazarus IDE under Carbon interface?

The Lazarus IDE with a Carbon interface is as good or better than others. You can still help by reporting bugs at Carbon interface internals#Carbon IDE Bugs.

When I execute application compiled for Carbon interface, it can't be focused

You have to execute Carbon application via Application Bundle. See Carbon Interface#Creating the Apple resource files how to create one.

I got a linking error when building Carbon application

You have forgotten to pass options to the linker to use Carbon Framework. See Carbon Interface#Compiler Options.

How can I rebuild LCL or Lazarus IDE for Carbon interface via terminal?

You can use the following command in Lazarus directory:

  • for LCL:
make lcl LCL_PLATFORM=carbon
  • for Lazarus IDE:
make all LCL_PLATFORM=carbon OPT="-k-framework -kCarbon -k-framework -kOpenGL"

under Leopard (OS X 10.5.x):

make all LCL_PLATFORM=carbon OPT="-k-framework -kCarbon -k-framework -kOpenGL -k'-dylib_file' \
    -k'/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib'"

I get error "make: -iVSPTPSOTO: Command not found" when I try to rebuild LCL or Lazarus IDE for Carbon interface via terminal.

The reason of this error is, that Free Pascal Compiler executables are not found in search path. You must add their path to the terminal profile, which is located at your home directory:

  • for Bash terminal in ".profile" file (e.g. use command "open -e ~/.profile" in terminal). At the end of file add this line:
export PATH=$PATH:/usr/local/bin
  • for tcsh terminal in ".tcshrc" or ".cshrc" or ".login" file (e.g. use command "open -e ~/.cshrc" in terminal). At the end of file add this line:
append_path PATH /usr/local/bin

, where "/usr/local/bin" is path to FPC executables. Save the result. It should work after terminal restart.

Unknown Stabs

The Unknown Stabs warnings are caused by a bug in the Mac OS X 10.5+ Linker and most Lazarus users can simply ignore them and they don't cause any harm in the software execution.

http://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg13235.html

That's because it also has to be partly fixed in the linker (which I didn't realise when I posted that message). The unknown stabs warnings (they're not errors afaik) are caused by stabs for local constants in functions/procedures (the linker interprets them as function stabs, because they have a very similar format and gcc does not generate stabs for constants).

If you want, you can download a patched linker from http://trappist.elis.ugent.be/~jmaebe/cctools/ (extract it to some directory, add a symbolic link to /usr/bin/as in the same directory, and point FPC to it using the -FD command line switch). That linker corresponds to the one shipped with Xcode 3.0 (+ the patches in that directory).

But since end users most likely won't have that patched linker (and because stabs has been deprecated by Apple), you may want to switch to dwarf instead on Mac OS X 10.5+

Dwarf issues

Compiling a project with -gw3 might crash the linker.

-gw3 crashes the linker because of a bug in the linker. It can be worked around by setting the version number of the DWARF debug info to 2 even though version 3 is generated, but that's a hack.

-gw2 does add debug information, just try debugging. On Mac OS X, DWARF debug information however remains in the object files and is not added to the main binary by the linker (to speed up linking). You can compile with -Xg to collect all DWARF debug information for an application into a .dSYM bundle using dsymutil.

Note that Apple's gdb crashes if you try to debug Lazarus after compiling it with -Xg, so that's not a good idea there.

Why my project doesn't work on earlier OSX versions?

It's common situation when a project you've compiled works on your OSX version, but not on earlier ones. For example, you're developing using OSX 10.6. The project runs fine for you, but not for your user using OSX 10.5. If you look to the console output you'd probably see the error like (or similar):

/Applications/ProjApp.app/Contents/MacOS/projapp ; exit; dyld: unknown
required load command 0x80000022
Trace/BPT trap
logout

It's caused, because you have compiled the project without earlier OS version compatibility. To add support for it, you need to specify the linker option (Project->Project Options->Linking->Options:

-macosx_version_min 10.5

"Pass Options to the Linker (Delimiter is space)" must be checked.


If you compile for 10.4 target, you should specify the 10.4 minimal version, and so on.


Remember, if your installed Xcode doesn't contain the backward compatibility SDK, the project linking would probably fail. You can always a the required SDKs using MacOSX installation disk or Xcode/iPhoneOS installation disk.


Please note, that iPhone SDK for OSX 10.6 comes without OSX 10.4 support.


You can find more linkers options at ld man page

User friendly OS version requirement

If your application requires a specific OS version and you don't want your app just to crash, you should provide the OS requirement version in bundle's Info.plist.

Which is the minimum Mac OS X version required by LCL-Carbon?

This information is documented here: LCL_Internals#Minimum_Toolkit_versions