CompileOnUnix/it

On recent linux distributions, FreeCAD is generally easy to build, since all dependencies are usually provided by the package manager. It basically involves 3 steps:
 * 1) Getting the FreeCAD source code
 * 2) Getting the dependencies (packages FreeCAD depends upon)
 * 3) Configure with "cmake" and Compile with "make"

Qui, di seguito, troverete le spiegazioni dettagliate di tutto il processo e delle particolarità che si possono incontrare. 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.

Ottenere il sorgente
Per poter compilare FreeCAD è necessario il codice sorgente. Ci sono 3 modi per ottenerlo:

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):

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

Github
Il repository ufficiale di FreeCAD è su Github: github.com/FreeCAD/FreeCAD

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.


 * Official FreeCAD source packages (distribution-independent): FreeCAD-0.17_pre.zip.

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.

either:
 * build-essential
 * cmake
 * python
 * python-matplotlib
 * libtool
 * libcoin60-dev (Debian Wheezy, Wheezy-backports, Ubuntu 13.04 and before)

or:
 * libcoin80-dev (Debian unstable(Jesse), testing, Ubuntu 13.10 and forward)

either:
 * libsoqt4-dev
 * libxerces-c-dev
 * libboost-dev
 * libboost-filesystem-dev
 * libboost-regex-dev
 * libboost-program-options-dev
 * libboost-signals-dev
 * libboost-thread-dev
 * libboost-python-dev
 * libqt4-dev
 * libqt4-opengl-dev
 * qt4-dev-tools
 * python-dev
 * python-pyside
 * pyside-tools
 * libopencascade-dev (official opencascade version)

or:
 * liboce*-dev (opencascade community edition)
 * oce-draw


 * libeigen3-dev
 * libqtwebkit-dev
 * libshiboken-dev
 * libpyside-dev
 * libode-dev
 * swig
 * libzipios++-dev
 * libfreetype6
 * libfreetype6-dev

Istruzioni supplementari per libcoin80-dev Debian wheezy-backports, unstable, testing, Ubuntu 13.10 e successive

Notare che liboce*-dev include le seguenti librerie: Potrebbe essere necessario installare singolarmente questi pacchetti tramite il loro nome.
 * liboce-foundation-dev
 * liboce-modeling-dev
 * liboce-ocaf-dev
 * liboce-visualization-dev
 * liboce-ocaf-lite-dev

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 yo can easily uninstall later)
 * python-pivy (needed for the 2D Drafting module)
 * python-qt4 (needed for the 2D Drafting module)
 * doxygen and libcoin60-doc (if you intend to generate source code documentation)
 * libspnav-dev (for 3Dconnexion devices support like the Space Navigator or Space Pilot)

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:


 * libspnav-devel (for 3Dconnexion devices support like the Space Navigator or Space Pilot)
 * pivy ( https://bugzilla.redhat.com/show_bug.cgi?id=458975 Pivy non è obbligatorio, ma è necessario per il modulo Draft )

Gentoo
Easiest way to check which packages are needed to compile FreeCAD is to check via portage:

emerge -pv freecad

This should give a nice list of extra packages that you need installed on your system.

OpenSUSE
Sono necessari i seguenti pacchetti: Per FreeCAD 0.14 stable e 0.15 unstable è necessario aggiungere librerie Eigen3 e swig, che non sembrano essere disponibili nei repositori standard. È possibile ottenerle e installarle con un solo clic da qui:
 * gcc
 * cmake
 * OpenCASCADE-devel
 * libXerces-c-devel
 * python-devel
 * libqt4-devel
 * libshiboken-devel
 * python-pyside-devel
 * python-pyside-tools
 * Coin-devel
 * SoQt-devel
 * boost-devel
 * libode-devel
 * libQtWebKit-devel
 * libeigen3-devel
 * gcc-fortran
 * freetype2
 * freetype2-devel
 * Eigen3
 * swig

Also, note that the Eigen3 Library from Factory Education was causing problems sometimes, so use the one from the KDE 4.8 Extra repo

Arch Linux
You will need the following libraries from the official repositories:


 * 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
 * swig
 * xerces-c

Also, make sure to check the AUR for any missing packages that are not on the repositories, currently:
 * 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 2D Drafting 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 ort elsewhere, you can compile pivy yourself:

Pivy compilation instructions

Using cMake
cMake is a newer build system which has the big advantage of being common for different target systems (Linux, Windows, MacOSX, etc). FreeCAD is now using the cMake system as its main building system. Compiling with cMake is usually very simple and happens in 2 steps. In the first step, cMake checks that every needed programs and libraries are present on your system and sets up all that's necessary for the subsequent compilation. You are given a few alternatives detailed below, but FreeCAD comes with sensible defaults. The second step is the compiling itself, which produces the FreeCAD executable. Changing any options for cmake away from their default values, is much easier with cmake-gui or other graphical cmake applications than with cmake on the command line, as the graphical applications will give you interactive feed back.

Since FreeCAD is a heavy application, compiling can take a bit of time (about 10 minutes on a fast machine, 30 minutes (or more) on a slow one)

In-source building
If you are unsure then, due to its limitations, do not make an in-source build, create an out-of-source build as explained in the next section. 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. This is fine if you are just looking at FreeCAD, and want to be able to remove it easily by just deleting that folder. But in case you are planning to compile it often, you are advised to make an out-of-source build, which offers many more advantages. The following commands will compile FreeCAD:

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 (via FREECAD_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. Also, set the build type to Debug if you want a debug build or Release if not. A Release build will run much faster than a Debug build. Sketcher becomes very slow with complex sketches if your FreeCAD is a Debug build. (NOTE: the space and "." after the cmake flags are CRITICAL!):

Per una Degug build

Oppure per una Release build

L'eseguibile di FreeCAD risiede quindi nella cartella "bin", e può essere lanciato con:

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.

Out-of-source build
If you intend to follow the fast evolution of FreeCAD, building in a separate folder is much more convenient. Every time you update the source code, cMake will then intelligently distinguish which files have changed, and recompile only what is needed. Out-of-source builds are specially handy when using the Git system, because you can easily try other branches without confusing the build system. To build out-of-source, simply create a build directory, distinct from your FreeCAD source folder, and, from the build folder, point cMake (or if using cmake-gui replace "cmake" in the code below with "cmake-gui") to the source folder:

L'eseguibile FreeCAD risiede quindi nella directory "bin" (all'interno della propria directory freecad-build).

Configuration options
There are a number of experimental or unfinished modules you may have to build if you want to work on them. To do so, you need to set the proper options for the configuration phase. Do it either on the command line, passing -D : = options to cMake or using one of the availables gui-frontends (eg for Debian, packages cmake-qt-gui or cmake-curses-gui). Changing any options for cmake away from their default values, is much easier with cmake-gui or other graphical cmake applications than with cmake on the command line, as they will give you interactive feed back.

As an example, to configure FreeCAD with the Assembly module built just tick the box in a cmake gui application (e.g. cmake-gui) or on the command line issue:

Le opzioni possibili sono elencate nel file CmakeLists.txt della radice FreeCAD.

Il plugin Qt designer
Se si desidera sviluppare del materiale Qt per FreeCAD, è necessario il plugin Qt Designer, che fornisce tutti i widget personalizzati di FreeCAD. Andare in

Finora non forniamo un makefile -- ma chiamando

lo creiamo. Una volta fatto, chiamando

si crea la libreria libFreeCAD_widgets.so. Per rendere nota questa libreria a Qt Designer è necessario copiare il file in $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:

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

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

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:

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.

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

(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.

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

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

Fedora 22/23/24
Posted by user [PrzemoF] in the forum.

{ echo "~/$MAIN_DIR already exist. Quitting.."; exit; }

cd $MAIN_DIR

git clone https://github.com/FreeCAD/FreeCAD.git

mkdir $BUILD_DIR

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 solociò che è cambiato, con delle compilazioni successive molto veloci. Con git o subversion è molto semplice aggiornare il codice sorgente:

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: