Compile on MacOS/fr: Difference between revisions
(Updating to match new version of source page) |
(Updating to match new version of source page) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
This page explains how to compile the latest FreeCAD source code on Mac OS X. |
|||
{{docnav|CompileOnUnix|Compiling (Speeding up)}} |
|||
This page describes how to compile the latest FreeCAD source on macOS X. ''Latest'' means the most recent commit to the master branch of the FreeCAD github repository. |
|||
== Prerequisites == |
|||
First of all, you will need to install the following software. |
|||
These instructions have been tested on macOS High Sierra |
|||
=== 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. |
|||
<pre> |
|||
xcode-select --install |
|||
</pre> |
|||
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. |
|||
This page serves as a quick start, and is not intended to be comprehensive with regard to describing all the available build options. |
|||
=== 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: [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. |
|||
If you just want to evaluate the latest pre-release build of FreeCAD, you can download pre-built binaries [https://github.com/FreeCAD/FreeCAD/releases from here]. |
|||
==== Homebrew ==== |
|||
To install Homebrew, enter the following in Terminal: |
|||
<pre> |
|||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
|||
</pre> |
|||
== Install Prerequisites == |
|||
==== MacPorts ==== |
|||
The following software must be installed to support the build process. |
|||
To install MacPorts, follow the instructions [https://www.macports.org/install.php from their website] |
|||
=== Homebrew Package Manager === |
|||
Homebrew is a command line based package manager for macOS. The [https://brew.sh/ Homebrew main page] provides an installation command line that you simply paste into a terminal window. |
|||
=== CMake === |
=== CMake === |
||
CMake is build tool that generates a build configuration based on variables you specify. You then issue the 'make' command to actually build that configuration. The command-line version of CMake is automatically installed as part of the Homebrew installation, above. If you prefer to use a GUI version of CMake, you can download it from [https://www.cmake.org/downloadDownload here]. |
|||
== Install Dependencies == |
|||
For the command line version of CMake, from a terminal use either Homebrew: |
|||
FreeCAD maintains a Homebrew 'tap' which installs the required formulas and dependencies. Issue the following brew commands in your terminal. |
|||
<pre> |
|||
brew install cmake |
|||
</pre> |
|||
or MacPorts: |
|||
<pre> |
|||
sudo port install cmake |
|||
</pre> |
|||
== Installing the Dependencies == |
|||
All of the needed libraries can be installed using either Homebrew or MacPorts. |
|||
<br /> |
|||
=== Homebrew Dependencies === |
|||
<pre> |
<pre> |
||
brew tap |
brew tap freecad/freecad |
||
brew |
brew install eigen |
||
brew install --only-dependencies freecad --with-packaging-utils |
|||
brew install boost eigen freetype oce python qt pyside pyside-tools xerces-c boost-python |
|||
brew install --without-framework --without-soqt sanelson/freecad/coin |
|||
brew install --HEAD pivy |
|||
brew install --with-oce nglib |
|||
</pre> |
</pre> |
||
Notes: |
|||
# 'brew install' may take quite a while, so you may want go grab a beverage. :-) |
|||
== Get the source == |
|||
In the following instructions, the source and build folders are created side-by-side under |
|||
<pre> |
|||
sudo port install boost eigen3 freetype oce py27-pyside-tools xercesc Coin |
|||
/Users/username/FreeCAD |
|||
</pre> |
|||
== Getting the source == |
|||
but you can use whatever folders you want. |
|||
<pre> |
<pre> |
||
mkdir ~/FreeCAD |
mkdir ~/FreeCAD |
||
cd ~/FreeCAD |
cd ~/FreeCAD |
||
</pre> |
</pre> |
||
The following command will clone the FreeCAD git repository into a directory called FreeCAD-git. |
|||
To get the FreeCAD source code, run: |
|||
<pre> |
<pre> |
||
git clone https://github.com/FreeCAD/ |
git clone https://github.com/FreeCAD/FreeCAD FreeCAD-git |
||
</pre> |
</pre> |
||
Create the build folder. |
|||
== Building FreeCAD == |
|||
First, create a new folder for the build: |
|||
<pre> |
<pre> |
||
mkdir ~/FreeCAD/build |
mkdir ~/FreeCAD/build |
||
</pre> |
</pre> |
||
<br /> |
|||
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. |
|||
== Run CMake == |
|||
Next, we will run CMake to generate the build configuration. Several options must be passed to CMake. The following table describes the options and gives some background. |
|||
=== CMake Options === |
=== CMake Options === |
||
Line 74: | Line 60: | ||
|- |
|- |
||
! Name !! Value !! Notes |
! Name !! Value !! Notes |
||
|- |
|||
| CMAKE_BUILD_TYPE || Release (STRING) || Release or Debug. Debug is generally used for developer-level testing but may also be required for user-level testing and troubleshooting. |
|||
|- |
|||
| BUILD_QT5 || 1 (BOOL) || Required to build with Qt5. |
|||
|- |
|- |
||
| CMAKE_PREFIX_PATH || "/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" (PATH) || Required to build with Qt5. See note below. |
|||
| 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. |
|||
|- |
|- |
||
| FREECAD_CREATE_MAC_APP || 1 (BOOL) || Create a FreeCAD.app bundle at the location specified in CMAKE_INSTALL_PREFIX, when the 'make install' command issued. |
|||
| CMAKE_BUILD_TYPE || Release || |
|||
|- |
|||
| CMAKE_INSTALL_PREFIX || "./.." (PATH) || Path where you want to generate the FreeCAD.app bundle. |
|||
|- |
|- |
||
| |
| FREECAD_USE_EXTERNAL_KDL || 1 (BOOL) || Required. |
||
|- |
|||
| FREETYPE_INCLUDE_DIR_freetype2 || /usr/local/include/freetype2 for Homebrew, /opt/local/include/freetype2 for MacPorts|| Only CMake version older than 3.1.0 |
|||
|- |
|- |
||
| BUILD_FEM_NETGEN || 1 ( |
| BUILD_FEM_NETGEN || 1 (BOOL) || Required. |
||
|- |
|||
| 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 Then when you run "make install" it will create the FreeCAD.app where ever CMAKE_INSTALL_PREFIX is set to. |
|||
|} |
|} |
||
Note: Command line to generate CMAKE_PREFIX_PATH: |
|||
<pre> |
|||
ls -d $(brew list -1 | grep qt | tail -1 | xargs brew --cellar)/*/lib/cmake |
|||
</pre> |
|||
=== CMake GUI === |
=== CMake GUI === |
||
Open the CMake app, and fill in the source and build folder fields. In this |
Open the CMake app, and fill in the source and build folder fields. In this example, 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. |
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. |
||
Line 97: | Line 89: | ||
Set options from the table above, then click '''Configure''' again and then '''Generate'''. |
Set options from the table above, then click '''Configure''' again and then '''Generate'''. |
||
=== CMake command line === |
=== CMake command line === |
||
Enter the following in the terminal. |
|||
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> |
<pre> |
||
$cd ~/FreeCAD/build |
$cd ~/FreeCAD/build |
||
$cmake \ |
|||
$cmake -DBUILD_ROBOT="0" ...options continue... -DPYTHON_LIBRARY="/some/path/" ../FreeCAD-git |
|||
-DCMAKE_BUILD_TYPE="Release" \ |
|||
-DBUILD_QT5=1 \ |
|||
-DCMAKE_PREFIX_PATH="/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" \ |
|||
-DFREECAD_USE_EXTERNAL_KDL=1 \ |
|||
-DBUILD_FEM_NETGEN=1 \ |
|||
-DFREECAD_CREATE_MAC_APP=1 \ |
|||
-DCMAKE_INSTALL_PREFIX="./.." \ |
|||
../FreeCAD-git/ |
|||
</pre> |
</pre> |
||
=== Make === |
|||
== Run make == |
|||
Finally, from a terminal run '''make''' to compile FreeCAD. |
|||
Finally, from a terminal run '''make''' to compile and link FreeCAD, and generate the app bundle. |
|||
<pre> |
<pre> |
||
cd ~/FreeCAD/build |
cd ~/FreeCAD/build |
||
make |
make -j5 install |
||
</pre> |
</pre> |
||
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. |
||
See also [[Compiling_(Speeding_up)|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. |
|||
If make finishes without any errors, you can now launch FreeCAD by double clicking the executable in the Finder. |
|||
== Updating == |
|||
FreeCAD development happens fast; everyday or so there are bug fixes or new features. To get these changes, run: |
|||
== Updating from Github == |
|||
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. |
|||
== Building with Qt4 == |
|||
FreeCAD has transitioned from Qt 4 to Qt 5. If you need to build with Qt4, the following additional steps are required. |
|||
# Append '--with-qt4' to the 'brew install' command. |
|||
# Do not specify BUILD_QT5 CMake option. |
|||
# Do not specify CMAKE_PREFIX_PATH CMake option |
|||
After you install Qt4, if you want to switch to building with Qt5, you will need to uninstall Qt4. |
|||
<pre> |
<pre> |
||
brew uninstall --ignore-dependencies --force cartr/qt4/shiboken@1.2 cartr/qt4/pyside@1.2 cartr/qt4/pyside-tools@1.2 cartr/qt4/qt |
|||
cd ~/FreeCAD/FreeCAD-git |
|||
</pre> |
|||
git pull |
|||
</pre> |
|||
And then repeat the compile step above. |
|||
== Troubleshooting == |
== Troubleshooting == |
||
=== Segfault on Qt5 launch === |
|||
If Qt4 was previously installed via brew, and you then build with Qt5, you may get a EXC_BAD_ACCESS (SEGSEGV) exception when launching the new Qt5 build. The fix for this is to manually uninstall Qt4. |
|||
<pre> |
|||
brew uninstall --ignore-dependencies --force cartr/qt4/shiboken@1.2 cartr/qt4/pyside@1.2 cartr/qt4/pyside-tools@1.2 cartr/qt4/qt-legacy-formula |
|||
</pre> |
|||
=== Fortran === |
=== 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, |
''"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 === |
=== OpenGL === |
||
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 |
|||
{{docnav/fr|[[CompileOnUnix/fr|CompileOnUnix]]|[[Third Party Libraries/fr|Third Party Libraries]]}} |
{{docnav/fr|[[CompileOnUnix/fr|CompileOnUnix]]|[[Third Party Libraries/fr|Third Party Libraries]]}} |
||
{{Userdocnavi}} |
|||
[[Category:Developer Documentation/fr]] |
[[Category:Developer Documentation/fr]] |
||
{{clear}} |
{{clear}} |
||
<languages/> |
Revision as of 10:03, 13 July 2019
This page describes how to compile the latest FreeCAD source on macOS X. Latest means the most recent commit to the master branch of the FreeCAD github repository.
These instructions have been tested on macOS High Sierra
This page serves as a quick start, and is not intended to be comprehensive with regard to describing all the available build options.
If you just want to evaluate the latest pre-release build of FreeCAD, you can download pre-built binaries from here.
Install Prerequisites
The following software must be installed to support the build process.
Homebrew Package Manager
Homebrew is a command line based package manager for macOS. The Homebrew main page provides an installation command line that you simply paste into a terminal window.
CMake
CMake is build tool that generates a build configuration based on variables you specify. You then issue the 'make' command to actually build that configuration. The command-line version of CMake is automatically installed as part of the Homebrew installation, above. If you prefer to use a GUI version of CMake, you can download it from here.
Install Dependencies
FreeCAD maintains a Homebrew 'tap' which installs the required formulas and dependencies. Issue the following brew commands in your terminal.
brew tap freecad/freecad brew install eigen brew install --only-dependencies freecad --with-packaging-utils
Notes:
- 'brew install' may take quite a while, so you may want go grab a beverage. :-)
Get the source
In the following instructions, the source and build folders are created side-by-side under
/Users/username/FreeCAD
but you can use whatever folders you want.
mkdir ~/FreeCAD cd ~/FreeCAD
The following command will clone the FreeCAD git repository into a directory called FreeCAD-git.
git clone https://github.com/FreeCAD/FreeCAD FreeCAD-git
Create the build folder.
mkdir ~/FreeCAD/build
Run CMake
Next, we will run CMake to generate the build configuration. Several options must be passed to CMake. The following table describes the options and gives some background.
CMake Options
Name | Value | Notes |
---|---|---|
CMAKE_BUILD_TYPE | Release (STRING) | Release or Debug. Debug is generally used for developer-level testing but may also be required for user-level testing and troubleshooting. |
BUILD_QT5 | 1 (BOOL) | Required to build with Qt5. |
CMAKE_PREFIX_PATH | "/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" (PATH) | Required to build with Qt5. See note below. |
FREECAD_CREATE_MAC_APP | 1 (BOOL) | Create a FreeCAD.app bundle at the location specified in CMAKE_INSTALL_PREFIX, when the 'make install' command issued. |
CMAKE_INSTALL_PREFIX | "./.." (PATH) | Path where you want to generate the FreeCAD.app bundle. |
FREECAD_USE_EXTERNAL_KDL | 1 (BOOL) | Required. |
BUILD_FEM_NETGEN | 1 (BOOL) | Required. |
Note: Command line to generate CMAKE_PREFIX_PATH:
ls -d $(brew list -1 | grep qt | tail -1 | xargs brew --cellar)/*/lib/cmake
CMake GUI
Open the CMake app, and fill in the source and build folder fields. In this example, 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
Enter the following in the terminal.
$cd ~/FreeCAD/build $cmake \ -DCMAKE_BUILD_TYPE="Release" \ -DBUILD_QT5=1 \ -DCMAKE_PREFIX_PATH="/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" \ -DFREECAD_USE_EXTERNAL_KDL=1 \ -DBUILD_FEM_NETGEN=1 \ -DFREECAD_CREATE_MAC_APP=1 \ -DCMAKE_INSTALL_PREFIX="./.." \ ../FreeCAD-git/
Run make
Finally, from a terminal run make to compile and link FreeCAD, and generate the app bundle.
cd ~/FreeCAD/build make -j5 install
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 by double clicking the executable in the Finder.
Updating from Github
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.
Building with Qt4
FreeCAD has transitioned from Qt 4 to Qt 5. If you need to build with Qt4, the following additional steps are required.
- Append '--with-qt4' to the 'brew install' command.
- Do not specify BUILD_QT5 CMake option.
- Do not specify CMAKE_PREFIX_PATH CMake option
After you install Qt4, if you want to switch to building with Qt5, you will need to uninstall Qt4.
brew uninstall --ignore-dependencies --force cartr/qt4/shiboken@1.2 cartr/qt4/pyside@1.2 cartr/qt4/pyside-tools@1.2 cartr/qt4/qt
Troubleshooting
Segfault on Qt5 launch
If Qt4 was previously installed via brew, and you then build with Qt5, you may get a EXC_BAD_ACCESS (SEGSEGV) exception when launching the new Qt5 build. The fix for this is to manually uninstall Qt4.
brew uninstall --ignore-dependencies --force cartr/qt4/shiboken@1.2 cartr/qt4/pyside@1.2 cartr/qt4/pyside-tools@1.2 cartr/qt4/qt-legacy-formula
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
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Start, Surface, TechDraw, Test Framework, Web
- Hubs: User hub, Power users hub, Developer hub