Dependencies of our programs on Mac OS X


  1. Mac OS X applications using Carbon (native look)
    1. Developers: Technical details
    2. Console
  2. Mac OS X applications using X Windows (and optionally GTK2)
    1. Dependencies to install
    2. Developers: additional stuff to install/configure
  3. Developers: creating Mac OS X applications

1. Mac OS X applications using Carbon (native look)

Since engine version 4.1.0 (view3dscene 3.13.0), our applications can have a native look on Mac OS X (Carbon), and do not need any extra dependencies (like X11 and GTK).

1.1. Developers: Technical details

We did it by using the LCL backend of CastleWindow. This uses Lazarus LCL under the hood, wrapping Lazarus TForm and TOpenGLControl inside a TCastleWindow. Although it still has some issues (see below), it gives us native look and a lot of stuff "for free".

Developers: If you want to use these features, you have to use the package alternative_castle_window_based_on_lcl.lpk instead of castle_window.lpk. This will give you CastleWindow unit that uses LCL and requires the castle_components package. If you open an existing source code, like view3dscene, you will have to change the dependencies in Lazarus Project inspector to use alternative_castle_window_based_on_lcl instead of castle_window. We hope to make it easier in the future by using the "Provides" option of Lazarus packages, but right now it doesn't do what we want — it can not "pull" extra depencies present in alternative package but not present in original.

This change allows CastleWindow-based programs, like view3dscene, to have native look on Mac OS X. Of course in your own programs you can also use Lazarus forms directly (with our TCastleControl) — this was always possible, and gives you the same native look through Lazarus.

On Mac OS X, the default LCL widgetset is Carbon right now.

1.2. Console

view3dscene uses a standard OS console for some stuff (e.g. for Console -> Print Current Camera...). You will not see this console if you run the program using the bundle (by double-clicking on the app in Finder, or in dock...).

To see the console output, run view3dscene from terminal:

cd directory-where-you-installed-view3dscene/

2. Mac OS X applications using X Windows (and optionally GTK2)

2.1. Dependencies to install

Before you run our programs on Mac OS X, you may need to install some additional software:

For libs installed by fink, you may have to add them to your libs path by command like

before executing programs. (you can add this to your .bashrc or similar file for comfort).

2.2. Developers: additional stuff to install/configure

To actually compile our programs on Mac OS X, developers may need to install a little more stuff. Of course FreePascal Compiler is required. For comfortable RAD development, you may also consider Lazarus (FPC is already included inside Lazarus installations, if you choose normal packages).

As of fink 0.29.21 (on Mac OS X 10.6.7), you should additionally install the fink "pango1-xft2-shlibs" package. Simple "fink install pango1-xft2-shlibs" should do the trick. This is necessary for successful linking.

The linker must know the location of fink and X11 libraries. If you have installed fink and X11 in standard locations, you can simply add these lines to your /etc/fpc.cfg file (see FPC documentation "Configuration file" to know where you can find your fpc.cfg file):


3. Developers: creating Mac OS X applications

A bunch of information about packaging your programs for Mac OS X follows.

  1. Make "Mac OS X bundle". It's basically a directory pretending to be an application.

    You can use Lazarus to create Mac OS X bundle. Or you can use our script (see script in our SVN repository), example usage is inside view3dscene sources.

  2. Optionally, add libraries (like libpng and vorbisfile) to the bundle. If you link to them dynamically (e.g. using our TDynLib.Load), you should load them from a path relative to BundlePath, like BundlePath + 'Contents/MacOS/libpng.dylib'.

    See Mac OS X Libraries on FPC wiki for general instructions how to include library inside a bundle.

  3. Pack into a nice .dmg file. See Building Fancy DMG Images on Mac OS X for nice description how to make the directories inside dmg look pretty, so you can visually suggest user to drag your application in the Applications folder.

    Alternative method of distribution Mac OS X applications is the package manager (.pkg). For normal applications (like games) the simpler .dmg is a better choice.