CompileOnMac

From FreeCAD Documentation
Revision as of 11:27, 19 September 2018 by Luc (talk | contribs)

Această pagină descrie modul de compilare a celei mai recente surse FreeCAD pe macOS X. Latest înseamnă cel mai recent angajament al filialei principale a depozitului Github al FreeCAD.

Această pagină servește ca un început rapid și nu intenționează să fie cuprinzătoare în ceea ce privește descrierea tuturor opțiunilor de compilare disponibile.

If you just want to evaluate the latest pre-release build of FreeCAD, you can download pre-built binaries from here.

Instalați cerințele preliminare

Următorul software trebuie instalat pentru a sprijini procesul de construire.

Managerul de pachete Homebrew

Homebrew este un manager de pachete de linie de comandă pentru MacOS. The Homebrew main page furnizează o linie de comandă de instalare pe care pur și simplu o inserați într-o fereastră de terminal.

CMake

CMake este un instrument de complilare care construiește o configurație de complilare bazată pe variabilele pe care le specificați. Apoi, emiteți comanda "make" pentru a compila configurația respectivă. 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 homebrew/science
brew tap freecad/freecad
brew install eigen
brew install --only-dependencies freecad --with-packaging-utils

Notes:

  1. '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.

  1. Append '--with-qt4' to the 'brew install' command.
  2. Do not specify BUILD_QT5 CMake option.
  3. 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

Depanare

Segfault on Qt5 launch

În cazul în care Qt4 a fost instalat anterior via brew, și apoi ați construit cu Qt5, puteți obține o excepție EXC_BAD_ACCESS (SEGSEGV) atunci când lansați compilarea nouli Qt5 . Remedierea pentru aceasta este de a dezinstala manual 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." în timpul configurației - versiunile mai vechi ale FreeCAD vor trebui să compileze instalate. Cu Homebrew, procedați la "brew install gcc" și încerdați configurarea din nou, dând lui cmake cale spre Fortran ie -DCMAKE_Fortran_COMPILER=/opt/local/bin/gfortran-mp-4.9 . Sau, de preferat, utilizați o versiune mai nouă a sursei FreeCAD!

OpenGL

See OpenGL on MacOS for OpenGL issues when Qt 4.8 and earlier are used on MacOS.

FreeType

Atunci când se utilizează versiuni CMake mai vechi de 3.1.0, este necesar să setați variabila CMake FREETYPE_INCLUDE_DIR_freetype2 manually, eg /usr/local/include/freetype2

CompileOnUnix
Compiling (Speeding up)