Difference between revisions of "Compile on MacOS"

From FreeCAD Documentation
Jump to navigation Jump to search
m (Should've actually tried building before the last edit...)
(Added MacPorts instructions, CLI for CMake, removed section on Application bundle (creating a bug tracker issue for that))
Line 1: Line 1:
<translate>
 
<!--T:52-->
 
 
This page explains how to compile the latest FreeCAD source code on Mac OS X.
 
This page explains how to compile the latest FreeCAD source code on Mac OS X.
  
== Prerequisites == <!--T:53-->
+
== Prerequisites ==
 
First of all, you will need to install the following software.
 
First of all, you will need to install the following software.
  
=== Xcode Development Tools === <!--T:54-->
+
=== Xcode Development Tools ===
 
Unless you want to use the Xcode IDE for FreeCAD development, you will only need to install the Command Line Tools. To do this on 10.9 and later, open Terminal, run the following command, and then click Install in the dialog that comes up.
 
Unless you want to use the Xcode IDE for FreeCAD development, you will only need to install the Command Line Tools. To do this on 10.9 and later, open Terminal, run the following command, and then click Install in the dialog that comes up.
</translate>
 
 
<pre>
 
<pre>
 
xcode-select --install
 
xcode-select --install
 
</pre>
 
</pre>
<translate>
 
<!--T:55-->
 
 
For other versions of OS X, you can get the package from the Apple developer [https://developer.apple.com/downloads/index.action?q=xcode downloads page] (sign in with the same Apple ID you use for other Apple services). Specifically, you will need to download Development Tools 3.2 for OS X 10.6, and Command Line Tools 4.8 for OS X 10.8.
 
For other versions of OS X, you can get the package from the Apple developer [https://developer.apple.com/downloads/index.action?q=xcode downloads page] (sign in with the same Apple ID you use for other Apple services). Specifically, you will need to download Development Tools 3.2 for OS X 10.6, and Command Line Tools 4.8 for OS X 10.8.
  
=== CMake === <!--T:56-->
+
=== Package Manager ===
Install the latest version of CMake from http://www.cmake.org/download. Although Homebrew will also install CMake, it only installs the command line executable.
+
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: [http://brew.sh/ Homebrew] and [https://www.macports.org/ MacPorts]. It's easiest to pick one package manager for your system, and not have multiple package managers installed concurrently.
  
=== Homebrew === <!--T:57-->
+
==== Homebrew ====
 
To install Homebrew, enter the following in Terminal:
 
To install Homebrew, enter the following in Terminal:
</translate>
 
 
<pre>
 
<pre>
 
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 
</pre>
 
</pre>
<translate>
+
 
== Getting the source == <!--T:58-->
+
==== MacPorts ====
In this guide, the source and build folders are created in '''/Users/username/FreeCAD''', but you can of course use whatever folder you want.
+
To install MacPorts, follow the instructions [https://www.macports.org/install.php from their website]
</translate>
+
 
 +
=== CMake ===
 +
FreeCAD uses [http://www.cmake.org/ CMake] to build the source.  Homebrew and MacPorts can install the command line version of CMake, or if you prefer using a GUI application, install the latest version from http://www.cmake.org/download.
 +
 
 +
For the command line version of CMake, from a terminal use either Homebrew:
 
<pre>
 
<pre>
mkdir ~/FreeCAD
+
brew install cmake
cd ~/FreeCAD
 
 
</pre>
 
</pre>
<translate>
+
or MacPorts:
<!--T:59-->
 
To get the FreeCAD source code, run:
 
</translate>
 
 
<pre>
 
<pre>
git clone git://git.code.sf.net/p/free-cad/code FreeCAD-git
+
sudo port install cmake
 
</pre>
 
</pre>
<translate>
 
<!--T:60-->
 
Alternatively, you can use the github mirror: https://github.com/FreeCAD/FreeCAD_sf_master.git
 
  
== Installing the Dependencies == <!--T:61-->
+
== Installing the Dependencies ==
All of the needed libraries can be installed using Homebrew.
+
All of the needed libraries can be installed using either Homebrew or MacPorts.
</translate>
+
 
 +
=== Homebrew Dependencies ===
 
<pre>
 
<pre>
 
brew tap homebrew/science
 
brew tap homebrew/science
Line 54: Line 46:
 
brew install --HEAD pivy
 
brew install --HEAD pivy
 
</pre>
 
</pre>
<translate>
+
 
== Compiling FreeCAD == <!--T:62-->
+
=== MacPorts Dependencies ===
 +
<pre>
 +
sudo port install boost eigen3 freetype oce python27 py27-pyside-tools xercesc Coin
 +
</pre>
 +
 
 +
== 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.
 +
<pre>
 +
mkdir ~/FreeCAD
 +
cd ~/FreeCAD
 +
</pre>
 +
To get the FreeCAD source code, run:
 +
<pre>
 +
git clone git://git.code.sf.net/p/free-cad/code FreeCAD-git
 +
</pre>
 +
Alternatively, you can use the github mirror: https://github.com/FreeCAD/FreeCAD_sf_master.git
 +
 
 +
== Building FreeCAD ==
 
First, create a new folder for the build:
 
First, create a new folder for the build:
</translate>
 
 
<pre>
 
<pre>
 
mkdir ~/FreeCAD/build
 
mkdir ~/FreeCAD/build
 
</pre>
 
</pre>
<translate>
+
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.
<!--T:63-->
 
Now you will need to run CMake to generate the build files. 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.  
 
  
<!--T:64-->
+
=== CMake Options ===
Next, click the '''Configure''' button. 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.
+
Required options will vary depending on whether Homebrew or MacPorts is used.
  
<!--T:65-->
+
Note: The paths for packages like OCE and Python are version specific -- change as needed.
 +
 
 +
==== Using Homebrew ====
 
{| class="wikitable" style="text-align:left"
 
{| class="wikitable" style="text-align:left"
 
|-
 
|-
! Option name !! Value  !! Notes
+
! Name !! Value  !! Notes
 
|-               
 
|-               
| BUILD_ROBOT || OFF (unchecked) || As of 12/19/2014, the robot module fails to build using newer versions of clang (OS X 10.9 and later)         
+
| BUILD_ROBOT || 0 (unchecked) || As of 12/19/2014, the robot module fails to build using newer versions of clang (OS X 10.9 and later)         
 
|-               
 
|-               
 
| CMAKE_BUILD_TYPE || Release ||
 
| CMAKE_BUILD_TYPE || Release ||
 
|-               
 
|-               
| FREECAD_USE_EXTERNAL_PIVY  || ON (checked) ||
+
| FREECAD_USE_EXTERNAL_PIVY  || 1 (checked) ||
 
|-               
 
|-               
 
| FREETYPE_INCLUDE_DIR_freetype2 || /usr/local/include/freetype2 || You will only need to set this if you are using a CMake version older than 3.1.0
 
| FREETYPE_INCLUDE_DIR_freetype2 || /usr/local/include/freetype2 || You will only need to set this if you are using a CMake version older than 3.1.0
Line 94: Line 102:
 
|-
 
|-
 
|}
 
|}
Note: The above paths for OCE and Python are for versions 0.16.1 and 2.7.9, respectively -- change as needed.
 
  
<!--T:66-->
+
==== Using MacPorts ====
Now click '''Configure''' again and then '''Generate'''.
+
{| class="wikitable" style="text-align:left"
 +
|-
 +
! Name !! Value  !! Notes
 +
|-             
 +
| BUILD_ROBOT || 0 (unchecked) || As of 12/19/2014, the robot module fails to build using newer versions of clang (OS X 10.9 and later)       
 +
|-             
 +
| CMAKE_BUILD_TYPE || Release ||
 +
|-             
 +
| FREECAD_USE_EXTERNAL_PIVY  || 1 (checked) ||
 +
|-             
 +
| FREETYPE_INCLUDE_DIR_freetype2 || /opt/local/include/freetype2 || UNTESTED - should only need to set this if you are using a CMake version older than 3.1.0
 +
|-             
 +
| OCE_DIR || /opt/local/Library/Frameworks/OCE.framework/Versions/0.15/Resources || For OCE v0.15, which is dated but the latest available in MacPorts 14 March 2015
 +
|-             
 +
| PYSIDERCC4BINARY || /opt/local/bin/pyside-rcc-2.7 ||
 +
|-             
 +
| PYSIDEUIC4BINARY || /opt/local/bin/pyside-uic-2.7 ||
 +
|-
 +
| PYTHON_EXECUTABLE || /opt/local/bin/python2.7 ||
 +
|-
 +
| PYTHON_INCLUDE_DIR || /opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ ||
 +
|-
 +
| PYTHON_LIBRARY || /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib ||
 +
|-
 +
| Shiboken_DIR || /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/cmake/Shiboken-1.2.2/ ||
 +
|-
 +
| PySide_DIR || /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/cmake/PySide-1.2.2/ ||
 +
|-
 +
|}
 +
=== 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.
 +
<pre>
 +
$cd ~/FreeCAD/build
 +
$cmake -DBUILD_ROBOT="0" ...options continue... -DPYTHON_LIBRARY="/some/path/" ../FreeCAD-git
 +
</pre>
  
<!--T:67-->
+
=== Make ===
Finally, run '''make''' to compile FreeCAD.
+
Finally, from a terminal run '''make''' to compile FreeCAD.
</translate>
 
 
<pre>
 
<pre>
 
cd ~/FreeCAD/build
 
cd ~/FreeCAD/build
 
make –j3
 
make –j3
 
</pre>
 
</pre>
<translate>
 
<!--T:68-->
 
 
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.
 
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.
  
 
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.
 
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.
== Creating an application bundle == <!--T:69-->
+
 
TODO
 
 
== Updating ==
 
== Updating ==
 
FreeCAD development happens fast; everyday or so there are bug fixes or new features. To get these changes, run:
 
FreeCAD development happens fast; everyday or so there are bug fixes or new features. To get these changes, run:
</translate>
 
 
<pre>
 
<pre>
 
cd ~/FreeCAD/FreeCAD-git
 
cd ~/FreeCAD/FreeCAD-git
 
git pull
 
git pull
 
</pre>
 
</pre>
<translate>
 
 
And then repeat the compile step above.
 
And then repeat the compile step above.
== Troubleshooting == <!--T:70-->
+
 
''"No CMAKE_Fortran_COMPILER could be found."'' during configuraiton - Older versions of FreeCAD will need a fortran compiler installed.  With homebrew, do "brew install gcc" and try configuring again, or preferably use a more current version of FreeCAD source.
+
== Troubleshooting ==
 +
''"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, or preferably use a more current version of FreeCAD source.
  
 
{{docnav|CompileOnUnix|Third Party Libraries}}
 
{{docnav|CompileOnUnix|Third Party Libraries}}
  
<!--T:71-->
 
 
[[Category:Developer Documentation]]
 
[[Category:Developer Documentation]]
  
</translate>
 
 
{{clear}}
 
{{clear}}
 
<languages/>
 
<languages/>

Revision as of 08:48, 14 March 2015

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.

Xcode Development Tools

Unless you want to use the Xcode IDE for FreeCAD development, you will only need to install the Command Line Tools. To do this on 10.9 and later, open Terminal, run the following command, and then click Install in the dialog that comes up.

xcode-select --install

For other versions of OS X, you can get the package from the Apple developer downloads page (sign in with the same Apple ID you use for other Apple services). Specifically, you will need to download Development Tools 3.2 for OS X 10.6, and Command Line Tools 4.8 for OS X 10.8.

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.

Homebrew

To install Homebrew, enter the following in Terminal:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

MacPorts

To install MacPorts, follow the instructions from their website

CMake

FreeCAD uses CMake to build the source. Homebrew and MacPorts can install the command line version of CMake, or if you prefer using a GUI application, install the latest version from http://www.cmake.org/download.

For the command line version of CMake, from a terminal use either Homebrew:

brew install cmake

or MacPorts:

sudo port install cmake

Installing the Dependencies

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

Homebrew Dependencies

brew tap homebrew/science
brew tap sanelson/freecad
brew install boost eigen freetype oce python qt pyside pyside-tools xerces-c
brew install --without-framework --without-soqt sanelson/freecad/coin
brew install --HEAD pivy

MacPorts Dependencies

sudo port install boost eigen3 freetype oce python27 py27-pyside-tools xercesc Coin

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 git://git.code.sf.net/p/free-cad/code FreeCAD-git

Alternatively, you can use the github mirror: https://github.com/FreeCAD/FreeCAD_sf_master.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 Options

Required options will vary depending on whether Homebrew or MacPorts is used.

Note: The paths for packages like OCE and Python are version specific -- change as needed.

Using Homebrew

Name Value Notes
BUILD_ROBOT 0 (unchecked) As of 12/19/2014, the robot module fails to build using newer versions of clang (OS X 10.9 and later)
CMAKE_BUILD_TYPE Release
FREECAD_USE_EXTERNAL_PIVY 1 (checked)
FREETYPE_INCLUDE_DIR_freetype2 /usr/local/include/freetype2 You will only need to set this if you are using a CMake version older than 3.1.0
OCE_DIR /usr/local/Cellar/oce/0.16.1/OCE.framework/Versions/0.16/Resources
PYSIDERCC4BINARY /usr/local/bin/pyside-rcc
PYSIDEUIC4BINARY /usr/local/bin/pyside-uic
PYTHON_EXECUTABLE /usr/local/bin/python
PYTHON_INCLUDE_DIR /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7
PYTHON_LIBRARY /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib

Using MacPorts

Name Value Notes
BUILD_ROBOT 0 (unchecked) As of 12/19/2014, the robot module fails to build using newer versions of clang (OS X 10.9 and later)
CMAKE_BUILD_TYPE Release
FREECAD_USE_EXTERNAL_PIVY 1 (checked)
FREETYPE_INCLUDE_DIR_freetype2 /opt/local/include/freetype2 UNTESTED - should only need to set this if you are using a CMake version older than 3.1.0
OCE_DIR /opt/local/Library/Frameworks/OCE.framework/Versions/0.15/Resources For OCE v0.15, which is dated but the latest available in MacPorts 14 March 2015
PYSIDERCC4BINARY /opt/local/bin/pyside-rcc-2.7
PYSIDEUIC4BINARY /opt/local/bin/pyside-uic-2.7
PYTHON_EXECUTABLE /opt/local/bin/python2.7
PYTHON_INCLUDE_DIR /opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/
PYTHON_LIBRARY /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
Shiboken_DIR /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/cmake/Shiboken-1.2.2/
PySide_DIR /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/cmake/PySide-1.2.2/

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 -DBUILD_ROBOT="0" ...options continue... -DPYTHON_LIBRARY="/some/path/" ../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.

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:

cd ~/FreeCAD/FreeCAD-git
git pull

And then repeat the compile step above.

Troubleshooting

"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, or preferably use a more current version of FreeCAD source.

Other languages:
Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎hrvatski • ‎italiano • ‎polski • ‎português • ‎português do Brasil • ‎română • ‎svenska • ‎čeština • ‎русский