Compile on MacOS: Difference between revisions
Renatorivo (talk | contribs) (Marked this version for translation) |
(Update instructions to match current practices. Remove obsolete MacPorts references.) |
||
Line 1: | Line 1: | ||
<translate> |
<translate> |
||
<!--T:72--> |
<!--T:72--> |
||
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. It is meant as a starting point for developing on FreeCAD; if you instead want to try using the latest pre-release version of FreeCAD, downloads are available from our continuous integration system at https://github.com/FreeCAD/FreeCAD/releases . |
||
⚫ | |||
⚫ | |||
== Prerequisites == <!--T:73--> |
== Prerequisites == <!--T:73--> |
||
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:74--> |
|||
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> |
|||
xcode-select --install |
|||
</pre> |
|||
<translate> |
|||
<!--T:75--> |
|||
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. |
|||
=== Package Manager === <!--T:76--> |
=== Package Manager === <!--T:76--> |
||
For FreeCAD, we usually use [https://brew.sh/ Homebrew], though MacPorts was used previously. |
|||
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. Currently (October 2015), Homebrew has more up-to-date libraries relating to FreeCAD than MacPorts. |
|||
==== Homebrew ==== <!--T:77--> |
|||
To install Homebrew, enter the following in Terminal: |
|||
</translate> |
|||
<pre> |
|||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
|||
</pre> |
|||
<translate> |
|||
==== MacPorts ==== <!--T:78--> |
|||
To install MacPorts, follow the instructions [https://www.macports.org/install.php from their website] |
|||
=== CMake === <!--T:79--> |
=== CMake === <!--T:79--> |
||
FreeCAD uses [http://www.cmake.org/ CMake] to build the source. CMake comes in two versions, command-line and GUI. |
FreeCAD uses [http://www.cmake.org/ CMake] to build the source. CMake comes in two versions, command-line and GUI. Use whichever you prefer. |
||
==== Homebrew ==== <!--T:105--> |
|||
<!--T:106--> |
<!--T:106--> |
||
The command-line version of CMake will be automatically installed by Homebrew in the prerequisites step, or the GUI version can be downloaded directly from https://www.cmake.org/download . |
|||
Command-line version: |
|||
<!--T:107--> |
|||
<pre> |
|||
brew install cmake |
|||
</pre> |
|||
<!--T:108--> |
|||
GUI: |
|||
<!--T:109--> |
|||
Install directly from http://www.cmake.org/download. |
|||
==== MacPorts ==== <!--T:110--> |
|||
<!--T:111--> |
|||
Command-line: |
|||
<!--T:112--> |
|||
<pre> |
|||
sudo port install cmake |
|||
</pre> |
|||
<!--T:113--> |
|||
GUI: |
|||
<!--T:114--> |
|||
<pre> |
|||
sudo port install cmake +gui |
|||
</pre> |
|||
== Installing the Dependencies == <!--T:82--> |
== Installing the Dependencies == <!--T:82--> |
||
All of the needed libraries can be installed using |
All of the needed libraries can be installed using Homebrew. We maintain a "tap" including a formula for FreeCAD, it can be used to get the relevant dependencies: |
||
''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'' |
|||
=== Homebrew Dependencies === <!--T:83--> |
|||
</translate> |
</translate> |
||
<pre> |
<pre> |
||
brew tap homebrew/science |
brew tap homebrew/science |
||
brew tap |
brew tap freecad/freecad |
||
⚫ | |||
brew install boost eigen freetype oce python qt pyside pyside-tools xerces-c boost-python |
|||
brew install -- |
brew install --only-dependencies freecad |
||
brew install --HEAD pivy |
|||
⚫ | |||
</pre> |
|||
<translate> |
|||
=== MacPorts Dependencies === <!--T:84--> |
|||
</translate> |
|||
<pre> |
|||
sudo port install qt4-mac boost eigen3 freetype oce py27-pyside-tools xercesc Coin vtk hdf5 |
|||
</pre> |
</pre> |
||
<translate> |
<translate> |
||
Line 101: | Line 37: | ||
<translate> |
<translate> |
||
<!--T:86--> |
<!--T:86--> |
||
To get the FreeCAD source code, |
To get the FreeCAD source code, this command will create a "clone" of the FreeCAD git repository in to a new directory called FreeCAD-git: |
||
</translate> |
</translate> |
||
<pre> |
<pre> |
||
Line 109: | Line 45: | ||
== Building FreeCAD == <!--T:88--> |
== Building FreeCAD == <!--T:88--> |
||
Create a new folder for the build: |
|||
</translate> |
</translate> |
||
<pre> |
<pre> |
||
Line 125: | Line 61: | ||
! Name !! Value !! Notes |
! Name !! Value !! Notes |
||
|- |
|- |
||
| FREECAD_USE_EXTERNAL_KDL || 1 (checked) || |
|||
| BUILD_ROBOT || 0 (unchecked) || The robot module depends on Orocos KDL, and the version of KDL included with FreeCAD currently (October 2015) doesn't build on recent MacOS. To build the robot module, install Orocos KDL (no MacPorts package is currently available), and specify FREECAD_USE_EXTERNAL_KDL=1 instead. |
|||
|- |
|||
| CMAKE_BUILD_TYPE || Release || |
|||
|- |
|||
| FREECAD_USE_EXTERNAL_PIVY || 1 (checked) || Homebrew only |
|||
|- |
|||
| FREETYPE_INCLUDE_DIR_freetype2 || /usr/local/include/freetype2 for Homebrew, /opt/local/include/freetype2 for MacPorts|| Only CMake version older than 3.1.0 |
|||
|- |
|- |
||
| CMAKE_BUILD_TYPE || Debug || Can be Debug or Release. Debug is generally used for development |
|||
⚫ | |||
|- |
|- |
||
⚫ | |||
| QT_QMAKE_EXECUTABLE || /opt/local/libexec/qt4/bin/qmake || MacPorts only (and probably temporary) |
|||
|- |
|- |
||
| FREECAD_CREATE_MAC_APP || 1 (checked) || If you want to make a FreeCAD.app |
| FREECAD_CREATE_MAC_APP || 1 (checked) || If you want to make a FreeCAD.app , this CMake option will cause "make install" to create a FreeCAD.app bundle in CMAKE_INSTALL_PREFIX . |
||
|} |
|} |
||
Line 166: | Line 96: | ||
<!--T:96--> |
<!--T:96--> |
||
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. |
||
⚫ | |||
⚫ | |||
<!--T:97--> |
<!--T:97--> |
||
Line 171: | Line 104: | ||
== Updating == <!--T:98--> |
== Updating == <!--T:98--> |
||
FreeCAD development happens fast; |
FreeCAD development happens fast; every day or so there are bug fixes or new features. To get the latest changes, use git to update the source directory (see [[Source code management]]), then re-run the CMake and make steps above. It is not usually necessary to start with a clean build directory in this case, and subsequent compiles will generally go much faster than the first one. |
||
</translate> |
|||
<pre> |
|||
cd ~/FreeCAD/FreeCAD-git |
|||
git pull |
|||
</pre> |
|||
<translate> |
|||
<!--T:99--> |
|||
And then repeat the compile step above. |
|||
== Troubleshooting == <!--T:100--> |
== Troubleshooting == <!--T:100--> |
||
=== Fortran === <!--T:101--> |
=== Fortran === <!--T:101--> |
||
''"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, |
''"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, giving 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 === <!--T:104--> |
=== OpenGL === <!--T:104--> |
||
See [[OpenGL_on_MacOS|OpenGL on MacOS]] |
See [[OpenGL_on_MacOS|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 |
|||
<!--T:102--> |
<!--T:102--> |
Revision as of 06:29, 19 February 2017
This page explains how to compile the latest FreeCAD source code on Mac OS X. It is meant as a starting point for developing on FreeCAD; if you instead want to try using the latest pre-release version of FreeCAD, downloads are available from our continuous integration system at https://github.com/FreeCAD/FreeCAD/releases .
Prerequisites
First of all, you will need to install the following software.
Package Manager
For FreeCAD, we usually use Homebrew, though MacPorts was used previously.
CMake
FreeCAD uses CMake to build the source. CMake comes in two versions, command-line and GUI. Use whichever you prefer.
The command-line version of CMake will be automatically installed by Homebrew in the prerequisites step, or the GUI version can be downloaded directly from https://www.cmake.org/download .
Installing the Dependencies
All of the needed libraries can be installed using Homebrew. We maintain a "tap" including a formula for FreeCAD, it can be used to get the relevant dependencies:
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, this command will create a "clone" of the FreeCAD git repository in to a new directory called FreeCAD-git:
git clone https://github.com/FreeCAD/FreeCAD FreeCAD-git
Building FreeCAD
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
Name | Value | Notes |
---|---|---|
FREECAD_USE_EXTERNAL_KDL | 1 (checked) | |
CMAKE_BUILD_TYPE | Debug | Can be Debug or Release. Debug is generally used for development |
BUILD_FEM_NETGEN | 1 (checked) | |
FREECAD_CREATE_MAC_APP | 1 (checked) | If you want to make a FreeCAD.app , this CMake option will cause "make install" to create a FreeCAD.app bundle in CMAKE_INSTALL_PREFIX . |
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... -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.
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; every day or so there are bug fixes or new features. To get the latest changes, use git to update the source directory (see Source code management), then re-run the CMake and make steps above. It is not usually necessary to start with a clean build directory in this case, and subsequent compiles will generally go much faster than the first one.
Troubleshooting
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, giving 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