Compile on MacOS/de: Difference between revisions

From FreeCAD Documentation
No edit summary
(Created page with "In den folgenden Anweisungen werden die Quell- und Bau Ordner nebeneinander unter")
Line 53: Line 53:
== Quelle beziehen ==
== Quelle beziehen ==


In den folgenden Anweisungen werden die Quell- und Bau Ordner nebeneinander unter
In the following instructions, the source and build folders are created side-by-side under


{{Code|code=
{{Code|code=

Revision as of 07:49, 16 January 2021

There is an experimental FreeCAD Docker container that is being tested for FreeCAD development. Read more about it at Compile on Docker

Übersicht

Diese Seite beschreibt, wie der neueste FreeCAD Quellcode unter MacOS X kompiliert wird. Für andere Plattformen, siehe Kompilieren.

Diese Anleitung wurde auf macOS Catalina mit Standard XCode 11.6 getestet. Es ist bekannt, dass sie auf macOS BigSur Beta mit XCode 12.0 Beta funktioniert. Wenn du planst, XCode Beta zu verwenden, stelle bitte sicher, dass du die Befehlszeilenwerkzeuge add on über ein dmg Paket herunterlädst, um einige libz Abhängigkeitsprobleme zu umgehen.

Diese Seite dient als Schnellstart und ist nicht als umfassende Beschreibung aller verfügbaren Aufbauoptionen gedacht.

Wenn du nur die neueste Vorabversion von FreeCAD evaluieren möchtest, kannst du vorgefertigte Binärdateien herunterladen von hier.

Installationsvoraussetzungen

Die folgende Software muss zur Unterstützung des Bau Prozesses installiert werden.

Die folgende Software muss installiert sein, um den Bau Prozess zu unterstützen.

Homebrew Paketverwalter

Homebrew ist ein kommandozeilenbasierter Paketmanager für macOS. Die Homebrew Hauptseite bietet eine Installations Befehlszeile, die du einfach in ein Terminalfenster einfügst.

CMake

CMake ist ein Bau Werkzeug, das eine Bau Konfiguration auf der Grundlage von Variablen erzeugt, die du angibst. Du gibst dann den Befehl "make" aus, um diese Konfiguration tatsächlich zu erstellen. Die Kommandozeilenversion von CMake wird automatisch als Teil der Homebrew Installation (siehe oben) installiert. Wenn du es vorziehst, eine GUI Version von CMake zu verwenden, kannst du es von hier herunterladen.

Abhängigkeiten einrichten

FreeCAD unterhält einen Homebrew 'Anzapf', der die erforderlichen Formeln und Abhängigkeiten installiert. Gib die folgenden brew Befehle in deinem Terminal ein.

brew tap freecad/freecad
brew install eigen
brew install --only-dependencies freecad --with-packaging-utils

Hinweise:

  1. 'brew install' kann eine ganze Weile dauern, also solltest du dir vielleicht ein Getränk holen :-).
  2. Homebrew wird derzeit mit Boost 1.73 ausgeliefert, das einen Fehler enthält. Um FreeCAD zu kompilieren, bearbeitest du bitte die Datei /usr/local/opt/boost/include/boost/geometry/index/detail/rtree/visitors/insert.hpp und deklarierst in Zeile 265 MembersHolder::visitor als öffentlichen Wert, indem du : MembersHolder::visitor durch : public MembersHolder::visitor ersetzst.


Quelle beziehen

In den folgenden Anweisungen werden die Quell- und Bau Ordner nebeneinander unter

/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

CMake ausführen

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 Optionen

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/opt/qt5/lib/cmake/;" ... (PATH) Required to build with Qt5. See note below. You also need to add path to VTK libraries and NGLIB libraries cmake configuration file.
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 Befehlszeile

Enter the following in the terminal.

export PREFIX_PATH="/usr/local/opt/qt/lib/cmake/;/usr/local/Cellar/nglib/v6.2.2007/Contents/Resources;/usr/local/Cellar/vtk@8.2/8.2.0_1/lib/cmake/"
$cd ~/FreeCAD/build
$cmake \
  -DCMAKE_BUILD_TYPE="Release"   \
  -DBUILD_QT5=1                  \
  -DWITH_PYTHON3=1               \
  -DCMAKE_PREFIX_PATH="$PREFIX_PATH" \
  -DPYTHON_EXECUTABLE="/usr/local/bin/python3" \
  -DFREECAD_USE_EXTERNAL_KDL=1   \
  -DCMAKE_CXX_FLAGS='-std=c++14' \
  -DBUILD_FEM_NETGEN=1           \
  -DFREECAD_CREATE_MAC_APP=1     \
  -DCMAKE_INSTALL_PREFIX="./.."  \
  ../FreeCAD-git/

make ausführen

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.

Aktualisierung von 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.

Bau mit Qt4 und Python 2.7

FreeCAD has transitioned from Qt 4 to Qt 5 as well as homebrew. Qt 4 is no longer available as an option for new build on macOS following Qt 5 transition. Python 2.7 has been deprecated within homebrew and upcoming macOS and we do not support it anymore for macOS build either.

Fehlersuche

Segfault beim Start von Qt5

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