OSX Build

From K-3D

Jump to: navigation, search


K-3D 0.7 running under Mac OSX 10.4.9 (Tiger)

Recent changes to K-3D's build system along with the maturation of FOSS tools on MacOSX have finally made a fully-supported build possible on MacOSX. Since this is a first for us, OSX developers are strongly encouraged to help polish K-3D for that platform.

Build Characteristics

  • K-3D version: 0.7
  • Build environment: MacPorts on OSX 10.4
  • Runtime environment: Mac OSX + X11


Build Instructions

Install MacPorts

Install CMake

Install MacPorts packages

Start X11, open an xterm, and install the required MacPorts 1.7 packages:

$ sudo port install mercurial
$ sudo port install boost +python25
$ sudo port install gtkmm
$ sudo port install gtkglext
$ sudo port install ossp-uuid

Note: If you are using older versions of MacPorts: you must install Boost 1.34 or later (previous versions had a problem detecting Python correctly).

You may also wish to install some or all of following optional packages, for enhanced functionality in K-3D:

$ sudo port install ImageMagick
$ sudo port install doxygen
$ sudo port install graphviz
$ sudo port install yafray

Setup the source and build trees

Use Mercurial to retrieve source code from the official K-3D repository (see Code for alternatives):

$ hg clone http://k3d.hg.sourceforge.net:8000/hgroot/k3d

This will create a "k3d" directory containing the K-3D sources. Create a separate build directory where the compiled binaries will reside:

$ mkdir k3d-build

Build configuration

Now you're ready to configure your new build directory using CMake:

$ cd k3d-build
$ ccmake ../k3d


Execute the following from your build directory to compile and link K-3D:

$ make

Once the build completes, you can test K-3D from the build directory (you must be running X11, of course):

$ make run


You can package K-3D in two ways on OSX:

  1. $ make package
  2. $ make package-bundle

The first option creates a PackageMaker installer, which will be familiar to Unix and Windows users, because it installs K-3D to a fixed location in the filesystem (currently /usr). Use this option if you will be running K-3D from a command-line, e.g for testing.

The second option produces a disk-image containing a "bundle" that users can easily download and install, simply by dragging the bundle icon to their local drive. This is the preferred mechanism for distributing all MacOSX software.


  • K-3D is built against the X11 OpenGL libraries in /usr/X11R6, not the OpenGL framework used by native OSX applications.
  • There are build problems with the GLX and OFFSCREEN modules, even though it should be possible to build GLX module against Apple's X11 OpenGL.
  • If you get an error:
Linking CXX shared library ../../lib/libk3dsdk-ngui.dylib
/usr/bin/libtool: can't locate file for: -lboost_program_options
/usr/bin/libtool: file: -lboost_program_options is not an object file (not allowed in a library)
/usr/bin/libtool: can't locate file for: -lboost_regex
/usr/bin/libtool: file: -lboost_regex is not an object file (not allowed in a library) 
make[2]: *** [lib/libk3dsdk-ngui.dylib] Error 1
make[1]: *** [k3dsdk/ngui/CMakeFiles/k3dsdk-ngui.dir/all] Error 2
make: *** [all] Error 2</nowiki>

because the boost library binaries in /opt/local/include have an extra _mt at the end, switch on advanced mode in ccmake, and change the library names for the boost_* stuff to have an extra _mt at the end, i.e.:

K3D_BOOST_PROGRAM_OPTIONS_LIB boost_program_options_mt

re-configure, re-generate, and re-build.

    • in leopard the boost_* may have -mt please check your /opt/local/lib to make sure.
  • In Leopard, if you get an error:
cycle in dylib re-exports with /usr/X11R6/lib/libGL.dylib

this is due to Apple's OpenGL framework new name clashing with X11's. To fix, edit your linker flags (CMAKE_EXE_LINKER_FLAGS, CMAKE_MODULE_LINKER_FLAGS, CMAKE_SHARED_LINKER_FLAGS) to:

-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib

by advanced mode in ccmake or editing CmakeCache.txt by hand. Re-configure, re-generate, and re-build.

Personal tools