210 lines
12 KiB
HTML
210 lines
12 KiB
HTML
<html><head><title>CompileOnMac</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>CompileOnMac</h1></div>
|
||
|
||
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="mw-parser-output"><p>This page describes how to compile the latest FreeCAD source on macOS X. <i>Latest</i> means the most recent commit to the master branch of the FreeCAD github repository.
|
||
</p><p>This page serves as a quick start, and is not intended to be comprehensive with regard to describing all the available build options.
|
||
</p><p>If you just want to evaluate the latest pre-release build of FreeCAD, you can download pre-built binaries <a rel="nofollow" class="external text" href="https://github.com/FreeCAD/FreeCAD/releases">from here</a>.
|
||
</p>
|
||
<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
|
||
<ul>
|
||
<li class="toclevel-1 tocsection-1"><a href="#Install_Prerequisites"><span class="tocnumber">1</span> <span class="toctext">Install Prerequisites</span></a>
|
||
<ul>
|
||
<li class="toclevel-2 tocsection-2"><a href="#Homebrew_Package_Manager"><span class="tocnumber">1.1</span> <span class="toctext">Homebrew Package Manager</span></a></li>
|
||
<li class="toclevel-2 tocsection-3"><a href="#CMake"><span class="tocnumber">1.2</span> <span class="toctext">CMake</span></a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toclevel-1 tocsection-4"><a href="#Install_Dependencies"><span class="tocnumber">2</span> <span class="toctext">Install Dependencies</span></a></li>
|
||
<li class="toclevel-1 tocsection-5"><a href="#Get_the_source"><span class="tocnumber">3</span> <span class="toctext">Get the source</span></a></li>
|
||
<li class="toclevel-1 tocsection-6"><a href="#Run_CMake"><span class="tocnumber">4</span> <span class="toctext">Run CMake</span></a>
|
||
<ul>
|
||
<li class="toclevel-2 tocsection-7"><a href="#CMake_Options"><span class="tocnumber">4.1</span> <span class="toctext">CMake Options</span></a></li>
|
||
<li class="toclevel-2 tocsection-8"><a href="#CMake_GUI"><span class="tocnumber">4.2</span> <span class="toctext">CMake GUI</span></a></li>
|
||
<li class="toclevel-2 tocsection-9"><a href="#CMake_command_line"><span class="tocnumber">4.3</span> <span class="toctext">CMake command line</span></a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toclevel-1 tocsection-10"><a href="#Run_make"><span class="tocnumber">5</span> <span class="toctext">Run make</span></a></li>
|
||
<li class="toclevel-1 tocsection-11"><a href="#Updating_from_Github"><span class="tocnumber">6</span> <span class="toctext">Updating from Github</span></a></li>
|
||
<li class="toclevel-1 tocsection-12"><a href="#Building_with_Qt4"><span class="tocnumber">7</span> <span class="toctext">Building with Qt4</span></a></li>
|
||
<li class="toclevel-1 tocsection-13"><a href="#Troubleshooting"><span class="tocnumber">8</span> <span class="toctext">Troubleshooting</span></a>
|
||
<ul>
|
||
<li class="toclevel-2 tocsection-14"><a href="#Segfault_on_Qt5_launch"><span class="tocnumber">8.1</span> <span class="toctext">Segfault on Qt5 launch</span></a></li>
|
||
<li class="toclevel-2 tocsection-15"><a href="#Fortran"><span class="tocnumber">8.2</span> <span class="toctext">Fortran</span></a></li>
|
||
<li class="toclevel-2 tocsection-16"><a href="#OpenGL"><span class="tocnumber">8.3</span> <span class="toctext">OpenGL</span></a></li>
|
||
<li class="toclevel-2 tocsection-17"><a href="#FreeType"><span class="tocnumber">8.4</span> <span class="toctext">FreeType</span></a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<h2><span class="mw-headline" id="Install_Prerequisites">Install Prerequisites</span></h2>
|
||
<p>The following software must be installed to support the build process.
|
||
</p>
|
||
<h3><span class="mw-headline" id="Homebrew_Package_Manager">Homebrew Package Manager</span></h3>
|
||
<p>Homebrew is a command line based package manager for macOS. The <a rel="nofollow" class="external text" href="https://brew.sh/">Homebrew main page</a> provides an installation command line that you simply paste into a terminal window.
|
||
</p>
|
||
<h3><span class="mw-headline" id="CMake">CMake</span></h3>
|
||
<p>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 <a rel="nofollow" class="external text" href="https://www.cmake.org/downloadDownload">here</a>.
|
||
</p>
|
||
<h2><span class="mw-headline" id="Install_Dependencies">Install Dependencies</span></h2>
|
||
<p>FreeCAD maintains a Homebrew 'tap' which installs the required formulas and dependencies. Issue the following brew commands in your terminal.
|
||
</p><p><br />
|
||
</p>
|
||
<pre>
|
||
brew tap homebrew/science
|
||
brew tap freecad/freecad
|
||
brew install eigen
|
||
brew install --only-dependencies freecad --with-packaging-utils
|
||
</pre>
|
||
<p>Notes:
|
||
</p>
|
||
<ol><li> 'brew install' may take quite a while, so you may want go grab a beverage. :-)</li></ol>
|
||
<h2><span class="mw-headline" id="Get_the_source">Get the source</span></h2>
|
||
<p>In the following instructions, the source and build folders are created side-by-side under
|
||
</p><p>/Users/username/FreeCAD
|
||
</p><p>but you can use whatever folders you want.
|
||
</p>
|
||
<pre>
|
||
mkdir ~/FreeCAD
|
||
cd ~/FreeCAD
|
||
</pre>
|
||
<p>The following command will clone the FreeCAD git repository into a directory called FreeCAD-git.
|
||
</p>
|
||
<pre>
|
||
git clone https://github.com/FreeCAD/FreeCAD FreeCAD-git
|
||
</pre>
|
||
<p>Create the build folder.
|
||
</p>
|
||
<pre>
|
||
mkdir ~/FreeCAD/build
|
||
</pre>
|
||
<p><br />
|
||
</p>
|
||
<h2><span class="mw-headline" id="Run_CMake">Run CMake</span></h2>
|
||
<p>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.
|
||
</p>
|
||
<h3><span class="mw-headline" id="CMake_Options">CMake Options</span></h3>
|
||
<table class="wikitable" style="text-align:left">
|
||
|
||
<tr>
|
||
<th> Name </th>
|
||
<th> Value </th>
|
||
<th> Notes
|
||
</th></tr>
|
||
<tr>
|
||
<td> CMAKE_BUILD_TYPE </td>
|
||
<td> Release (STRING) </td>
|
||
<td> Release or Debug. Debug is generally used for developer-level testing but may also be required for user-level testing and troubleshooting.
|
||
</td></tr>
|
||
<tr>
|
||
<td> BUILD_QT5 </td>
|
||
<td> 1 (BOOL) </td>
|
||
<td> Required to build with Qt5.
|
||
</td></tr>
|
||
<tr>
|
||
<td> CMAKE_PREFIX_PATH </td>
|
||
<td> "/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" (PATH) </td>
|
||
<td> Required to build with Qt5. See note below.
|
||
</td></tr>
|
||
<tr>
|
||
<td> FREECAD_CREATE_MAC_APP </td>
|
||
<td> 1 (BOOL) </td>
|
||
<td> Create a FreeCAD.app bundle at the location specified in CMAKE_INSTALL_PREFIX, when the 'make install' command issued.
|
||
</td></tr>
|
||
<tr>
|
||
<td> CMAKE_INSTALL_PREFIX </td>
|
||
<td> "./.." (PATH) </td>
|
||
<td> Path where you want to generate the FreeCAD.app bundle.
|
||
</td></tr>
|
||
<tr>
|
||
<td> FREECAD_USE_EXTERNAL_KDL </td>
|
||
<td> 1 (BOOL) </td>
|
||
<td> Required.
|
||
</td></tr>
|
||
<tr>
|
||
<td> BUILD_FEM_NETGEN </td>
|
||
<td> 1 (BOOL) </td>
|
||
<td> Required.
|
||
</td></tr></table>
|
||
<p>Note: Command line to generate CMAKE_PREFIX_PATH:
|
||
</p>
|
||
<pre>
|
||
ls -d $(brew list -1 | grep qt | tail -1 | xargs brew --cellar)/*/lib/cmake
|
||
</pre>
|
||
<h3><span class="mw-headline" id="CMake_GUI">CMake GUI</span></h3>
|
||
<p>Open the CMake app, and fill in the source and build folder fields. In this example, it would be <b>/Users/username/FreeCAD/FreeCAD-git</b> for the source, and <b>/Users/username/FreeCAD/build</b> for the build folder.
|
||
</p><p>Next, click the <b>Configure</b> 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 <b>Unix Makefiles.</b> Configuring will fail the first time because there are some options that need to be changed. Note: You will need to check the <b>Advanced</b> checkbox to get all of the options.
|
||
</p><p>Set options from the table above, then click <b>Configure</b> again and then <b>Generate</b>.
|
||
</p>
|
||
<h3><span class="mw-headline" id="CMake_command_line">CMake command line</span></h3>
|
||
<p>Enter the following in the terminal.
|
||
</p>
|
||
<pre>
|
||
$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/
|
||
|
||
</pre>
|
||
<h2><span class="mw-headline" id="Run_make">Run make</span></h2>
|
||
<p>Finally, from a terminal run <b>make</b> to compile and link FreeCAD, and generate the app bundle.
|
||
</p>
|
||
<pre>
|
||
cd ~/FreeCAD/build
|
||
make –j5 install
|
||
</pre>
|
||
<p>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.
|
||
</p><p>See also <a href="/wiki/Compiling_(Speeding_up)" title="Compiling (Speeding up)">Compiling - Speeding up</a>.
|
||
</p><p>If make finishes without any errors, you can now launch FreeCAD by double clicking the executable in the Finder.
|
||
</p>
|
||
<h2><span class="mw-headline" id="Updating_from_Github">Updating from Github</span></h2>
|
||
<p>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 <a href="Source_code_management.html" title="Source code management">Source code management</a>), 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.
|
||
</p>
|
||
<h2><span class="mw-headline" id="Building_with_Qt4">Building with Qt4</span></h2>
|
||
<p>FreeCAD has transitioned from Qt 4 to Qt 5. If you need to build with Qt4, the following additional steps are required.
|
||
</p>
|
||
<ol><li> Append '--with-qt4' to the 'brew install' command.</li>
|
||
<li> Do not specify BUILD_QT5 CMake option.</li>
|
||
<li> Do not specify CMAKE_PREFIX_PATH CMake option</li></ol>
|
||
<p>After you install Qt4, if you want to switch to building with Qt5, you will need to uninstall Qt4.
|
||
</p>
|
||
<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
|
||
</pre>
|
||
<h2><span class="mw-headline" id="Troubleshooting">Troubleshooting</span></h2>
|
||
<h3><span class="mw-headline" id="Segfault_on_Qt5_launch">Segfault on Qt5 launch</span></h3>
|
||
<p>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.
|
||
</p>
|
||
<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>
|
||
<h3><span class="mw-headline" id="Fortran">Fortran</span></h3>
|
||
<p><i>"No CMAKE_Fortran_COMPILER could be found."</i> 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!
|
||
</p>
|
||
<h3><span class="mw-headline" id="OpenGL">OpenGL</span></h3>
|
||
<p>See <a href="OpenGL_on_MacOS.html" title="OpenGL on MacOS">OpenGL on MacOS</a> for OpenGL issues when Qt 4.8 and earlier are used on MacOS.
|
||
</p>
|
||
<h3><span class="mw-headline" id="FreeType">FreeType</span></h3>
|
||
<p>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
|
||
</p>
|
||
|
||
<div style="clear:both"></div>
|
||
</div>
|
||
|
||
|
||
|
||
</div>
|
||
|
||
</div><div class="printfooter">
|
||
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=CompileOnMac&oldid=243451">http://www.freecadweb.org/wiki/index.php?title=CompileOnMac&oldid=243451</a>"</div>
|
||
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
|
||
</div>
|
||
</div>
|
||
<div id="mw-navigation">
|
||
<h2>Navigation menu</h2>
|
||
|
||
</body></html> |