Compilazione in Unix

From FreeCAD Documentation
Jump to: navigation, search
This page is a translated version of the page CompileOnUnix and the translation is 25% complete.

Outdated translations are marked like this.
Other languages:
български • ‎čeština • ‎Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎polski • ‎português • ‎português do Brasil • ‎română • ‎русский • ‎svenska • ‎Türkçe • ‎中文(中国大陆)‎

Nelle distribuzioni Linux recenti FreeCAD si compila facilmente, dato che di solito tutte le dipendenze sono fornite dal gestore di pacchetti. Fondamentalmente si tratta di eseguire 3 passaggi:

  1. Ottenere il codice sorgente di FreeCAD
  2. Ottenere le dipendenze (i pacchetti da cui dipende FreeCAD)
  3. Configurare con "cmake" e compilare con "make"

Qui, di seguito, troverete le spiegazioni dettagliate di tutto il processo, delle particolarità che si possono incontrare e alcuni script di build,. Se trovate qualcosa di sbagliato o di non aggiornato nel testo successivo (le distribuzioni Linux cambiano spesso), o se utilizzate una distribuzione che non è elencata, per favore aiutateci a correggerlo.

Git

Il modo migliore e più veloce per ottenere il codice è quello di clonare il repository git di sola lettura ora ospitato in GitHub (bisogna avere il pacchetto git installato):

git clone https://github.com/FreeCAD/FreeCAD.git freecad-code

Questo crea una copia locale della versione più recente del codice sorgente di FreeCAD in una nuova directory chiamata "freecad-code".

Pacchetto sorgente

In alternativa è possibile scaricare il pacchetto sorgente, ma potrebbe già essere abbastanza vecchio, e quindi è sempre meglio ottenere i sorgenti più recenti tramite git o github.

Ottenere le dipendenze

Per compilare FreeCAD sotto Linux è necessario installare prima tutte le librerie indicate nella pagina Librerie di terze parti. Notare che i nomi e la disponibilità delle librerie dipendono dalla vostra distribuzione. Notare che se non si utilizza la versione più recente della propria distribuzione, alcuni dei pacchetti indicati in seguito potrebbero mancare dal vostro repository. In questo caso, cercare nel paragrafo sottostante dedicato alle Distribuzioni vecchie e non convenzionali.

Passa al paragrafo Compilare FreeCAD

Debian e Ubuntu

Su sistemi Debian-based (Debian, Ubuntu, Mint, etc...) è abbastanza facile ottenere tutte le dipendenze che devono essere installate. La maggior parte delle librerie sono disponibili tramite apt-get o il gestore dei pacchetti synaptic.

If you already installed FreeCAD from the official repositories, you can install its build dependencies with this single line of code in a terminal:

 sudo apt build-dep freecad
  • build-essential
  • cmake
  • python
  • python-matplotlib
  • libtool

either:

  • libcoin80-dev (Debian jessie, stretch, Ubuntu 16.04 to 18.10)

or:

  • libboost-dev
  • libboost-date-time-dev
  • libboost-filesystem-dev
  • libboost-graph-dev
  • libboost-iostreams-dev
  • libboost-program-options-dev
  • libboost-python-dev
  • libboost-regex-dev
  • libboost-signals-dev
  • libboost-serialization-dev
  • libboost-thread-dev
  • libeigen3-dev
  • libopencv-dev | libcv-dev
  • libgts-bin
  • libgts-dev
  • libkdtree++-dev
  • libmedc-dev
  • libproj-dev
  • libvtk6-dev | libvtk7-dev
  • libx11-dev
  • libxerces-c-dev
  • libzipios++-dev
  • lsb-release
  • swig

with Qt4 and Python 2 (for Debian jessie, stretch, Ubuntu 16.04):

  • libqt4-dev
  • libqt4-opengl-dev
  • libqtwebkit-dev
  • libshiboken-dev
  • libpyside-dev
  • python-dev
  • python-pivy
  • python-ply
  • python-pyside
  • pyside-tools
  • qt4-dev-tools

or with Qt5 and Python 3 (Debian buster, Ubuntu 19.04 and forward, as well as Ubuntu 18.04/18.10 with the freecad-stable/freecad-daily PPAs added to your software sources:

  • libqt5opengl5-dev
  • libqt5svg5-dev
  • libqt5webkit5-dev or qtwebengine5-dev
  • libqt5x11extras5-dev
  • libpyside2-dev
  • libshiboken2-dev
  • pyside2-tools
  • python3-dev
  • python3-pivy
  • python3-ply
  • python3-pyside2.qtcore
  • python3-pyside2.qtgui
  • python3-pyside2.qtsvg
  • python3-pyside2.qtwidgets
  • python3-pyside2uic
  • qtbase5-dev
  • qttools5-dev

either:

  • libocct*-dev (official opencascade version, up-to-date, available in Debian buster and Ubuntu 18.10 and forward, as well as Ubuntu 18.04 with the freecad-stable/freecad-daily PPAs added to your software sources)
  • occt-draw

or:

  • liboce*-dev (opencascade community edition, outdated, available in Debian jessie, stretch, Ubuntu 16.04 and forward)
  • oce-draw

Notare che liboce*-dev include le seguenti librerie:

  • liboce-foundation-dev
  • liboce-modeling-dev
  • liboce-ocaf-dev
  • liboce-visualization-dev
  • liboce-ocaf-lite-dev

Potrebbe essere necessario installare singolarmente questi pacchetti tramite il loro nome.

Opzionalmente è anche possibile installare questi pacchetti extra:

  • libsimage-dev (to make Coin to support additional image file formats)
  • checkinstall (to register your installed files into your system's package manager, so you can easily uninstall later)
  • python-matplotlib
  • doxygen and libcoin80-doc (if you intend to generate source code documentation)
  • libspnav-dev (for 3Dconnexion devices support like the Space Navigator or Space Pilot)


Single command for Qt5 and Python 3 (requires Pyside2 available in Debian buster and the freecad-stable/freecad-daily PPAs)

sudo apt install cmake debhelper dh-exec dh-python libboost-date-time-dev libboost-dev libboost-filesystem-dev libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-serialization-dev libboost-signals-dev libboost-thread-dev libcoin-dev libcv-dev libeigen3-dev libgts-bin libgts-dev libkdtree++-dev libmedc-dev libocct-data-exchange-dev libocct-ocaf-dev libocct-visualization-dev libopencv-dev libproj-dev libpyside2-dev libqt5opengl5-dev libqt5svg5-dev libqt5x11extras5-dev libshiboken2-dev libspnav-dev libvtk7-dev libx11-dev libxerces-c-dev libzipios++-dev lsb-release occt-draw pyside2-tools python-matplotlib python3-dev python3-pivy python3-ply python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qtsvg python3-pyside2.qtwidgets python3-pyside2uic qtbase5-dev qttools5-dev libqt5webkit5-dev swig

Single command for Qt4 and Python 2

sudo apt install cmake debhelper dh-exec dh-python libboost-date-time-dev libboost-dev libboost-filesystem-dev libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-serialization-dev libboost-signals-dev libboost-thread-dev libcoin80-dev libopencv-dev libeigen3-dev libgts-bin libgts-dev libkdtree++-dev libmedc-dev libocct-data-exchange-dev libocct-ocaf-dev libocct-visualization-dev libproj-dev libpyside-dev libqt4-dev libqt4-opengl-dev libqtwebkit-dev libshiboken-dev libspnav-dev libvtk6-dev libx11-dev libxerces-c-dev libzipios++-dev lsb-release occt-draw pyside-tools python-dev python-matplotlib python-pivy python-ply swig

Gli utenti di Ubuntu 16.04 vedano anche queste ulteriori instruzioni .

Fedora

Sono necessari i seguenti pacchetti:

  • gcc-c++ (or possibly another C++ compiler?)
  • cmake
  • doxygen
  • swig
  • gettext
  • dos2unix
  • desktop-file-utils
  • libXmu-devel
  • freeimage-devel
  • mesa-libGLU-devel
  • OCE-devel
  • python
  • python-devel
  • python-pyside-devel
  • pyside-tools
  • boost-devel
  • tbb-devel
  • eigen3-devel
  • qt-devel
  • qt-webkit-devel
  • ode-devel
  • xerces-c
  • xerces-c-devel
  • opencv-devel
  • smesh-devel
  • coin3-devel

(if coin2 is the latest available for your version of Fedora, use packages from http://www.zultron.com/rpm-repo/)

  • soqt-devel
  • freetype
  • freetype-devel

E opzionalmente:

Gentoo

Il modo più semplice per controllare quali pacchetti sono necessari per compilare FreeCAD è quello di verificare tramite Portage:

emerge -pv freecad

Questo dovrebbe dare una bella lista di pacchetti extra che è necessario installare sul proprio sistema.

If FreeCAD is not available on portage, it is available on the waebbl overlay. The issue tracker on the waebbl overlay Github may help guide through some issues you may come across. The overlay provides freecad-9999, which you can choose to compile, or simply use to get the dependencies.

layman -a waebbl </div> </div>

openSUSE

Tumbleweed

The following commands will install the packages required for building FreeCAD with Qt5 and Python 3.

zypper in --no-recommends -t pattern devel_C_C++ devel_qt5

zypper in libqt5-qtbase-devel libqt5-qtsvg-devel libqt5-qttools-devel boost-devel swig libboost_program_options-devel libboost_mpi_python3-devel libboost_system-devel libboost_program_options-devel libboost_regex-devel libboost_python3-devel libboost_thread-devel libboost_system-devel libboost_headers-devel libboost_graph-devel python3 python3-devel python3-matplotlib python3-matplotlib-qt5 python3-pyside2 python3-pyside2-devel python3-pivy gcc gcc-fortran cmake occt-devel libXi-devel opencv-devel libxerces-c-devel Coin-devel SoQt-devel freetype2-devel eigen3-devel libode6 vtk-devel libmed-devel hdf5-openmpi-devel openmpi2-devel netgen-devel freeglut-devel libspnav-devel f2c doxygen dos2unix glew-devel

The following command will install Qt Creator and the GNU Project Debugger.

zypper in libqt5-creator gdb

If any packages are missing, then you can check the Tumbleweed "FreeCAD.spec" file on the Open Build Service.

Also, check to see if there are any patches you need to apply (such as 0001-find-openmpi2-include-files.patch).

Leap

If there is a difference between the available packages on Tumbleweed and Leap, then you can read the Leap "FreeCAD.spec" file on the Open Build Service to determine the required packages.

Arch Linux

You will need the following libraries from the official repositories:

  • boost-libs
  • curl
  • hicolor-icon-theme
  • libspnav
  • opencascade
  • python2-matplotlib
  • shared-mime-info
  • xerces-c
  • boost
  • cmake
  • desktop-file-utils
  • eigen
  • gcc-fortran
  • swig

Also, make sure to check the AUR for any missing packages that are not on the repositories, currently:

  • coin
  • python2-pivy
  • python2-pyside
  • python2-pyside-tools
  • python2-shiboken
  • qtwebkit
  • med (Modelisation et Echanges de Donnees)
sudo pacman -S boost-libs curl hicolor-icon-theme libspnav opencascade python2-pivy python2-matplotlib python2-pyside python2-shiboken qtwebkit shared-mime-info xerces-c boost cmake coin desktop-file-utils eigen gcc-fortran med python2-pyside-tools

Older and non-conventional distributions

On other distributions, we have very few feedback from users, so it might be harder to find the required packages. Try first locating the required libraries mentioned in Third Party Libraries. Beware that some of them might have a slightly different package name in your distribution (such as name, libname, name-dev, name-devel, etc...).

You also need the GNU gcc compiler version equal or above 3.0.0. g++ is also needed because FreeCAD is completely written in C++. During the compilation some Python scripts get executed. So the Python interpreter has to work properly. To avoid any linker problems during the build process it is also a good idea to have the library paths either in your LD_LIBRARY_PATH variable or in your ld.so.conf file. This is normally already the case in recent distributions.

For more details have also a look to README.Linux in your sources.

Pivy

Pivy is not needed to build FreeCAD or to run it, but it is needed for the Draft module to work. If you are not going to use that module, you won't need pivy. By November 2015 the obsolete version of Pivy included with FreeCAD source code will no longer compile on many systems, due to its age. If you cannot find Pivy in your distribution's packages repository or elsewhere, you can compile pivy yourself:

Pivy compilation instructions

Compilare FreeCAD

FreeCAD uses CMake as its main build system. CMake is a build system available on all major operating systems. Compiling with CMake is usually very simple and happens in two steps.

  1. CMake checks that every needed program and library is present on your system, and configures the build system for the second step. FreeCAD has several configuration options to choose from, but it comes with sensible defaults. Some alternatives are detailed below.
  2. The compilation itself, which produces the FreeCAD executable.

Poiché FreeCAD è un'applicazione pesante, la compilazione può richiedere un po' di tempo (circa 10 minuti su una macchina veloce, 30 minuti, o più, su una lenta)

Costruzione Out-of-source

Se intendete seguire la rapida evoluzione di FreeCAD, convenie costruire in una cartella separata (Out-of-source build). Ogni volta che il codice sorgente viene aggiornato, cMake riconosce intelligentemente i file che sono stati modificati e ricompila solo ciò che è necessario. La costruzione Out-of-source è particolarmente utile quando si utilizza il sistema Git, perché si può facilmente provare altri rami senza confondere il sistema di compilazione. Per costruire out-of-source, è sufficiente creare una cartella di generazione, distinta dalla cartella di origine FreeCAD, e, dalla cartella di compilazione, indirizzare CMake (o se si usa cmake-gui sostituire nel codice seguente "cmake" con "cmake-gui") verso la cartella di origine :

$ mkdir freecad-build
$ cd freecad-build
$ cmake ../freecad-code (or whatever the path is to your FreeCAD source folder)
$ make -j$(nproc --ignore=2)

The FreeCAD executable will then reside in the freecad-build/bin directory.

Costruzione In-source

Se avete dei dubbi, a causa di suoi limiti, non fate una costruzione interna al sorgente, ma create una costruzione out-of-source, come spiegato nella sezione successiva. FreeCAD può essere costruito nel sorgente (in-source), il che significa che tutti i file risultanti dalla compilazione si trovano nella stessa cartella del codice sorgente. Questo va bene per "dare un'occhiata" a FreeCAD, e permette di rimuoverlo facilmente eliminando semplicemente la sua cartella. Quando si prevede di compilarlo spesso, si consiglia invece di fare una costruzione esterna al sorgente (out-of-source) perchè offre maggiori vantaggi. I seguenti comandi compilano FreeCAD:

In-source builds are fine if you are just looking at FreeCAD, and want to be able to remove it easily by just deleting that folder. However, if you are unsure where to build, do not make an in-source build. Create an out-of-source build as explained earlier. However FreeCAD can be built in-source, which means that all the files resulting from the compilation stay in the same folder as the source code.

The following commands will compile FreeCAD:

$ cd freecad-source
$ cmake .
$ make -j$(nproc --ignore=2)

The FreeCAD executable will then reside in the freecad-source/bin directory.

How to repair your source code directory after accidentally running an in-source build

This is a method, using Git, to repair your source code directory after accidentally running an in-source build. If you do not clear it, subsequent runs of cmake may not capture all of your new options.

$ > .gitignore
$ git clean -df
$ git reset --hard HEAD

The first line clears the .gitignore file. This ensures that the following clean and reset commands will affect everything in the directory and will not ignore items matching the expressions in .gitignore. The second line deletes all files and directories that are not tracked by the git repository, and then the reset will reset any changes to tracked files (including the first command which cleared the .gitignore file.

Configuration

By passing different options to CMake, you can change how FreeCAD is compiled. This can be useful for several purposes. For example, by calling CMake like this, you can instruct it to not build the FEM module:

cmake -D BUILD_FEM:BOOL=OFF ''path-to-freecad-root''

All possible options are listed in FreeCAD's root CMakeLists.txt file. Try searching for the string OPTION. Alternatively, use the command cmake -LH. Below, we've listed some of the more relevant options you may want to configure.

To pass a value for an option you find in the CMakeLists.txt file, use the following flag: -D <var>:<type>=<value>

Per una Degug build
$ cmake -DCMAKE_BUILD_TYPE=Debug .
Oppure per una Release build
$ cmake -DCMAKE_BUILD_TYPE=Release .

External, or internal Pivy

If you want to use your system's copy of Pivy, which you most commonly will, then if not on Linux, set the compiler flag to use the correct pivy with -DFREECAD_USE_EXTERNAL_PIVY=1. Using external Pivy became the default for Linux, during development of FreeCAD 0.16, so it does not need to be manually set when compiling this version onwards, on Linux.

Building for Qt5

By default, FreeCAD builds for Qt4. It is possible to build for Qt5 by enabling the -DBUILD-QT5 option.

cmake -DBUILD_QT5=ON .

Building for a specific Python version

By default, FreeCAD may only detect Python 2. It is possible to choose how to build for a specific version of Python (e.g. Python 2 or Python 3) by setting some cmake options. An example for Python 3 is shown below:

cmake -DPYTHON_LIBRARY=/usr/lib64/libpython3.6m.so \
    -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m \
    -DPYTHON_PACKAGES_PATH=/usr/lib64/python3.6/site-packages \
    -DPYTHON_EXECUTABLE=/usr/bin/python3.6 \
    .

The locations and version numbers of your Python files and directories will be different depending on which distribution you are using. You can find them using the Unix locate or which commands.

Building with Qt Creator

To use Qt5 and Python 3, add the following to the bottom of: Projects → Manage Kits → Kits → Default (or your kit) → CMake Configuration:

PYTHON_EXECUTABLE=/usr/bin/python3.7
PYTHON_INCLUDE_DIR=/usr/include/python3.7m
PYTHON_LIBRARY=/usr/lib64/libpython3.7m.so
PYTHON_PACKAGES_PATH=/usr/lib64/python3.7/site-packages
BUILD_QT5=ON

The paths used for python depend on your system and might need to be changed. "python3 -m site" in a terminal will at least help with determining the site-package directory.

If you aren't using Python 3.7.x, you will need to replace the "3.7". From a terminal you can check with "python3 -V" and ignore the number furthest right.

Switch Projects → Run → Run Configuration from FreeCADMainCMD to FreeCADMain (unless you want the command line only version).

Qt designer plugin

If you want to develop Qt stuff for FreeCAD, you'll need the Qt Designer plugin that provides all custom widgets of FreeCAD. Go to:

freecad/src/Tools/plugins/widget

So far we don't provide a makefile -- but calling

qmake plugin.pro

creates it. Once that's done, calling

make

will create the library libFreeCAD_widgets.so. To make this library known to Qt Designer you have to copy the file to $QTDIR/plugin/designer

Doxygen

If you feel bold enough to dive in the code, you could take advantage to build and consult Doxygen generated FreeCAD's Source documentation

Making a debian package

Se prevedete di costruire un pacchetto Debian indipendente dai sorgenti è necessario installare prima i seguenti pacchetti:

dh-make
devscripts

#optional, used for checking if packages are standard-compliant
lintian

Per costruire un pacchetto, aprire una console, andare nella directory di FreeCAD e chiamare

debuild

Quando il pacchetto è costruito, è possibile utilizzare lintian per verificare se il pacchetto contiene errori

#replace by the name of the package you just created
lintian your-fresh-new-freecad-package.deb

Risoluzione dei problemi

Note for 64bit systems

When building FreeCAD for 64-bit there is a known issue with the OpenCASCADE 64-bit package. To get FreeCAD running properly you might need to run the ./configure script with the additional define _OCC64 set:

./configure CXXFLAGS="-D_OCC64"

For Debian based systems this workaround is not needed when using the prebuilt package because there the OpenCASCADE package is built to set internally this define. Now you just need to compile FreeCAD the same way as described above.

Script di build automatico

Ecco tutto quello che vi serve per una compilazione completa di FreeCAD. Si tratta di uno script di approccio e funziona su una distro di recente installazione. I comandi richiedono la password di root (per l'installazione di pacchetti) e talvolta di riconoscere un'impronta digitale per il server di un repository esterno o un repository https-subversion. Questi script dovrebbero funzionare su versioni a 32 e 64 bit. Essi sono scritti per diverse versioni, e dovrebbero essere eseguibili anche su versioni successive, con o senza grandi cambiamenti.

Se disponete di uno script per la vostra distribuzione preferita, siete pregati di inviarlo! Noi lo incorporeremo in questo articolo.

Ubuntu

These scripts provide a reliable way to install the correct set of dependencies required to build and run FreeCAD on Ubuntu. They make use of the FreeCAD Ubuntu PPA repositories, and should work on any version of Ubuntu targeted by the PPA. The 'daily' PPA targets recent versions of Ubuntu, and the 'stable' PPA targets all officially supported versions of Ubuntu.

This script installs dependencies for the daily development snapshot of FreeCAD.

#!/bin/sh
sudo add-apt-repository --enable-source ppa:freecad-maintainers/freecad-daily && sudo apt-get update
# Install the dependencies needed to build FreeCAD
sudo apt-get build-dep freecad-daily
# Install the dependencies needed to run FreeCAD (and a build of FreeCAD itself)
sudo apt-get install freecad-daily

This script installs dependencies for the latest stable release of FreeCAD. (For Ubuntu 12.04, omit "--enable-source" from the add-apt-repository command.)

#!/bin/sh
sudo add-apt-repository --enable-source ppa:freecad-maintainers/freecad-stable && sudo apt-get update
# Install the dependencies needed to build FreeCAD
sudo apt-get build-dep freecad
# Install the dependencies needed to run FreeCAD (and a build of FreeCAD itself)
sudo apt-get install freecad

(These scripts also install the PPA build of FreeCAD itself, as a side effect. You could then uninstall that while leaving the dependencies in place. However, leaving it installed will enable the package manager to keep the set of dependencies up to date, which is useful if you are following the development for a long time.)

After installing the dependencies, please see the generic instructions for getting the source code, running CMake, and compiling. The following script is an example of one way to do this.

#!/bin/sh

# checkout the latest source
git clone https://github.com/FreeCAD/FreeCAD.git freecad

# go to source dir
cd freecad

# open cmake-gui window
cmake-gui .

# build configuration
cmake .

# build FreeCAD
# Note: to speed up build use all CPU cores: make -j$(nproc)
make

OpenSUSE 12.2

No external Repositories are needed to compile FreeCAD 0.13 with this release. However, there is an imcompatability with python3-devel which needs to be removed. FreeCAD can be compiled from GIT similar to in OpenSUSE 12.2

# install needed packages for development
sudo zypper install gcc cmake OpenCASCADE-devel libXerces-c-devel \
python-devel libqt4-devel python-qt4 Coin-devel SoQt-devel boost-devel \
libode-devel libQtWebKit-devel libeigen3-devel gcc-fortran git swig
 
# create new dir, and go into it
mkdir FreeCAD-Compiled 
cd FreeCAD-Compiled
 
# get the source
git clone https://github.com/FreeCAD/FreeCAD.git free-cad
 
# Now you will have subfolder in this location called free-cad. It contains the source
 
# make another dir for compilation, and go into it
mkdir FreeCAD-Build1
cd FreeCAD-Build1 
 
# build configuration 
cmake ../free-cad
 
# build FreeCAD
make
 
# test FreeCAD
cd bin
./FreeCAD -t 0

Since you are using git, next time you wish to compile you do not have to clone everything, just pull from git and compile once more

# go into free-cad dir created earlier
cd free-cad
 
# pull
git pull
 
# get back to previous dir
cd ..
 
# Now repeat last few steps from before.
 
# make another dir for compilation, and go into it
mkdir FreeCAD-Build2
cd FreeCAD-Build2
 
# build configuration 
cmake ../free-cad
 
# build FreeCAD
# Note: to speed up build use all CPU cores: make -j$(nproc)
make
 
# test FreeCAD
cd bin
./FreeCAD -t 0

Debian Squeeze

# get the needed tools and libs
sudo apt-get install build-essential python libcoin60-dev libsoqt4-dev \
libxerces-c2-dev libboost-dev libboost-date-time-dev libboost-filesystem-dev \
libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev \
libboost-serialization-dev libboost-signals-dev libboost-regex-dev \
libqt4-dev qt4-dev-tools python2.5-dev \
libsimage-dev libopencascade-dev \
libsoqt4-dev libode-dev subversion cmake libeigen2-dev python-pivy \
libtool autotools-dev automake gfortran
 
# checkout the latest source
git clone https://github.com/FreeCAD/FreeCAD.git freecad
 
# go to source dir
cd freecad
 
# build configuration 
cmake .
 
# build FreeCAD
# Note: to speed up build use all CPU cores: make -j$(nproc)
make
 
# test FreeCAD
cd bin
./FreeCAD -t 0

Fedora 27/28/29

Posted by user [PrzemoF] in the forum.

#!/bin/bash

ARCH=$(arch)

MAIN_DIR=FreeCAD
BUILD_DIR=build

#FEDORA_VERSION=27
#FEDORA_VERSION=28
FEDORA_VERSION=29

PACKAGES="gcc cmake gcc-c++ boost-devel zlib-devel swig eigen3 qt-devel \
shiboken shiboken-devel pyside-tools python-pyside python-pyside-devel xerces-c \
xerces-c-devel OCE-devel smesh graphviz python-pivy python-matplotlib tbb-devel \
 freeimage-devel Coin3 Coin3-devel med-devel vtk-devel"

FEDORA_29_PACKAGES="boost-python2 boost-python3 boost-python2-devel boost-python3-devel"

if [ "$FEDORA_VERSION" = "29" ]; then
    PACKAGES="$PACKAGES $FEDORA_29_PACKAGES"
fi

echo "Installing packages required to build FreeCAD"
sudo dnf -y install $PACKAGES
cd ~
mkdir $MAIN_DIR || { echo "~/$MAIN_DIR already exist. Quitting.."; exit; }
cd $MAIN_DIR
git clone https://github.com/FreeCAD/FreeCAD.git
mkdir $BUILD_DIR || { echo "~/$BUILD_DIR already exist. Quitting.."; exit; }
cd $BUILD_DIR
cmake ../FreeCAD 
make -j$(nproc)

Aggiornare il codice sorgente

Lo sviluppo di FreeCAD è veloce, quasi ogni giorno ci sono correzioni di bug o nuove funzionalità. Il sistema cmake consente di aggiornare il codice sorgente in modo intelligente e di ricompilare solo ciò che è cambiato, con delle compilazioni successive molto veloci. Con git o subversion è molto semplice aggiornare il codice sorgente:

#Replace with the location where you cloned the source code the first time
cd freecad-code
#If you are using git
git pull

Move into the appropriate build directory and run cmake again (as cmake updates the version number data for the Help menu, ...about FreeCAD), however you do not need to add the path to source code after "cmake", just a space and a dot:

#Replace with the location of the build directory
cd ../freecad-build
cmake .
# to use all cpu cores change to: make -j$(nproc)
make

Link

Vedere anche Velocizzare la compilazione Come velocizzare la compilazione di FreeCAD

Arrow-left.svg Compilare in Windows Pagina precedente:
Pagina successiva: Compilare in Mac Arrow-right.svg