CompileOnUnix/es

En distribuciones recientes de linux, FreeCAD es sencillo de construir ya que todas las dependencias usualmente las provee el administrador de paquetes. Involucra 3 pasos básicamente:

Debajo encontrarás explicaciones detalladas sobre todo el proceso y peculiaridades que puedas encontrar. Si encuentras que algo está mal o no está actualizado en el texto debajo (distribuciones Linux cambian frecuentemente), o si usas una distribución que no está listada, por favor ayúdanos a corregirlo.

Obteniendo el código fuente
Antes de que puedas compilar FreeCAD, necesitas el código fuente. Hay 3 maneras de conseguirlo:

Git
El modo más rápido y el mejor para obtener el código es clonar el repositorio de Git (necesitas tener instalado el paquete Git):

Esto colocará una copia de la versión más reciente del código fuente de FreeCAD en el directorio llamado "free-cad-code". La primera vez que intentes conectarte al servidor free-cad.git.sourceforge.net recibirás un mensaje solicitándote que autentifiques la clave SSH de sourceforge, la cual es segura de aceptar normalmente (puedes checar sus claves SSH en la página web de sourceforge si no estás seguro)

Paquete fuente
Alternativamente, puedes descargar un paquete fuente, pero podrían ser demasiado antiguos por lo que es mejor obtener el código más reciente vía git o github.

Obtener las dependencias
Para compilar FreeCAD en Linux debes de instalar todas las librerías mencionadas en Third Party Libraries/es primero. Ten en cuenta que los nombres y disponibilidad de las librerías dependen de tu distribución. Considera que si no estás en la versión más reciente de tu distribución algunos de los paquetes debajo pueden estar faltando en tus repositorios. En ese caso ve la sección de Distribuciones antiguas y no convencionales debajo.

Skip to Compile FreeCAD

Debian and Ubuntu
On Debian-based systems (Debian, Ubuntu, Mint, etc...) it is quite easy to get all needed dependencies installed. Most of the libraries are available via apt-get or synaptic package manager.

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

either:
 * build-essential
 * cmake
 * python
 * python-matplotlib
 * libtool
 * libcoin80-dev (Debian jessie, stretch, Ubuntu 16.04 to 18.10)

or:
 * libcoin-dev (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)

with Qt4 and Python 2 (for Debian jessie, stretch, Ubuntu 16.04):
 * 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
 * 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

Note that liboce*-dev/libocct*-dev include the following libraries (substitute oce for occt): You may have to install these packages by individual name.
 * liboce-foundation-dev
 * liboce-modeling-dev
 * liboce-ocaf-dev
 * liboce-visualization-dev
 * liboce-ocaf-lite-dev

Optionally you can also install these extra packages:
 * 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)

Single command for Qt4 and Python 2

Ubuntu 16.04 users please see also these additional instructions.

Fedora
You need the following packages :


 * 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

And optionally :


 * libspnav-devel (for 3Dconnexion devices support like the Space Navigator or Space Pilot)
 * pivy ( https://bugzilla.redhat.com/show_bug.cgi?id=458975 Pivy is not mandatory but needed for the Draft module)

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.

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

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

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

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)

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.

Debajo hay información adicional para algunas librería que podrían no estar presentes en los repositorios de tu distribución.

Pivy
Pivy no es necesario para construir FreeCAD o ejecutarlo, pero es requerido para que el módulo 2D Drafting funcione. Si no planeas utilizar este módulo, no necesitas pivy. En e momento de escribir esto, Pivy es muy reciente y puede que no esté en los repositorios de tu distribución. Si no puedes encontrarlos, puedes descargar los paquetes debian/ubuntu en la página de descargas de FreeCAD:

Pivy instrucciones de compilación

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

Dado que FreeCAD es una aplicación pesada, compilarlo tomará un poco de tiempo (alrededor de 10 minutos en una máquina rápida, 30 minutos en una máquina lenta)

Construir fuera de la fuente
Si pretendes seguir la ráida evolución de FreeCAD, construir en una carpeta separada es mucho más conveniente. Cada vez que actualices el código fuente, cMake distinguirá inteligentemente que archivos han cambiado y recompilará solamente aquello que sea necesario. Construcciones fuera de la fuente son especialmente útiles al utilizar el sistema Git, ya que puedes probar fácilmente otras ramas sin confundir el sistema de construcción. Para construir fuera de la fuente, simplemente crea un directorio de construcción, distinto a tu carpeta fuente de freecad, y, desde la carpeta de construccion, indícale a cMake la carpeta fuente:

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

Construyendo en la fuente
Freecad puede ser construido en la fuente, lo que significa que todos los archivos resultantes de la compilación permanecen en la misma carpeta que el código fuene. Esto está bien si solamente estás probando FreeCAD, y quieres ser capaz de removerlo fácilmente con solo eliminar la carpeta. Pero si planeas compilar frecuentemente, se te recomienda crear una construcción fuera de la fuente, lo que ofrece varias ventajas. Los siguientes comandos compilarán 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:

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.

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</tt> 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:

All possible options are listed in FreeCAD's root CMakeLists.txt</tt> file. Try searching for the string OPTION</tt>. Alternatively, use the command cmake -LH</tt>. 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</tt> file, use the following flag: -D : =

For a Release build
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.

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</tt>. 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</tt> option.

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</tt> options. An example for Python 3 is shown below:

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</tt> or which</tt> 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:

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:

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

creates it. Once that's done, calling

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

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
If you plan to build a Debian package out of the sources you need to install those packages first:

To build a package open a console, simply go to the FreeCAD directory and call

Once the package is built, you can use lintian to check if the package contains errors

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.

Automatic build scripts
Here is all what you need for a complete build of FreeCAD. It's a one-script-approach and works on a fresh installed distro. The commands will ask for root password (for installation of packages) and sometime to acknowledge a fingerprint for an external repository server or https-subversion repository. These scripts should run on 32 and 64 bit versions. They are written for different versions, but are also likely to run on a later version with or without major changes.

If you have such a script for your preferred distro, please send it! We will incorporate it into this article.

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 27/28/29
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

Updating the source code
FreeCAD development happens fast, everyday or so there are bug fixes or new features. The cmake systems allows you to intelligently update the source code, and only recompile what has changed, making subsequent compilations very fast. Updating the source code with git or subversion is very easy:

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:

Links
See also Compiling - Speeding up How to speed up compilation