Compile on MacOS/en

This page explains how to compile the latest FreeCAD source code on Mac OS X.

Prerequisites
First of all, you will need to install the following software.

Package Manager
You will want to use a package manager to install prerequisite software, this page gives instructions for two of the common package managers in use for OS X: Homebrew and MacPorts. It's easiest to pick one package manager for your system, and not have multiple package managers installed concurrently. Currently (October 2015), Homebrew has more up-to-date libraries relating to FreeCAD than MacPorts.

CMake
FreeCAD uses CMake to build the source. CMake comes in two versions, command-line and GUI. Choose the one you prefer.

Command-line version:

Installing the Dependencies
All of the needed libraries can be installed using either Homebrew or MacPorts.

''Note that there is currently a bug where the dependencies aren't all installed on the first run of brew install... - the duplicate line below is intentional'' brew tap homebrew/science brew tap freecad/freecad brew install --only-dependencies freecad brew install --only-dependencies freecad

Getting the source
In this guide, the source and build folders are created in /Users/username/FreeCAD, but you can of course use whatever folder you want. mkdir ~/FreeCAD cd ~/FreeCAD To get the FreeCAD source code, run: git clone https://github.com/FreeCAD/FreeCAD FreeCAD-git

Building FreeCAD
First, create a new folder for the build: mkdir ~/FreeCAD/build Now you will need to run CMake to generate the build files. Several options will need to be given to CMake, which can be accomplished either with the CMake GUI application, or via the command line.

CMake GUI
Open the CMake app, and fill in the source and build folder fields. In this case, it would be /Users/username/FreeCAD/FreeCAD-git for the source, and /Users/username/FreeCAD/build for the build folder.

Next, click the Configure button to populate the list of configuration options. This will display a dialog asking you to specify what generator to use. Leave it at the default Unix Makefiles. Configuring will fail the first time because there are some options that need to be changed. Note: You will need to check the Advanced checkbox to get all of the options.

Set options from the table above, then click Configure again and then Generate.

CMake command line
Open a terminal, cd in to the build directory that was created above. Run cmake with options from the table above, following the formula -D(Name)="(Value)", and the path to your FreeCAD source directory as the final argument. $cd ~/FreeCAD/build $cmake -DFREECAD_USE_EXTERNAL_KDL="1" ...options continue... -DFREECAD_CREATE_MAC_APP ="1" ../FreeCAD-git

Make
Finally, from a terminal run make to compile FreeCAD. cd ~/FreeCAD/build make –j3 The -j option specifies how many make processes to run at once. One plus the number of CPU cores is usually a good number to use. However, if compiling fails for some reason, it is useful to rerun make without the -j option, so that you can see exactly where the error occurred.

See also Compiling - Speeding up How to speed up compilation.

If make finishes without any errors, you can now launch FreeCAD, either from Terminal with ./bin/FreeCAD, or by double clicking the executable in Finder.

Updating
FreeCAD development happens fast; everyday or so there are bug fixes or new features. To get these changes, run:

Fortran
"No CMAKE_Fortran_COMPILER could be found." during configuration - Older versions of FreeCAD will need a fortran compiler installed. With Homebrew, do "brew install gcc" and try configuring again, for Macports, do "sudo port install gcc49" and give cmake the path to Fortran ie -DCMAKE_Fortran_COMPILER=/opt/local/bin/gfortran-mp-4.9. Or, preferably use a more current version of FreeCAD source!

OpenGL
See OpenGL on MacOS for OpenGL issues when Qt 4.8 and earlier are used on MacOS.

FreeType
When using CMake versions older than 3.1.0, it's necessary to set CMake variable FREETYPE_INCLUDE_DIR_freetype2 manually, eg /usr/local/include/freetype2