Compile on Linux/es

Vista general
En las distribuciones recientes de Linux, FreeCAD es generalmente fácil de construir, ya que todas las dependencias suelen ser proporcionadas por el administrador de paquetes. Básicamente implica 3 pasos:
 * 1) Obtener el código fuente de FreeCAD
 * 2) Obtener las dependencias o paquetes de los que depende FreeCAD
 * 3) Configurar con  y compilar con

A continuación, encontrará explicaciones detalladas de todo el proceso, algunos build scripts, y las particularidades que puede encontrar. Si encuentras algo incorrecto o desactualizado en el texto de abajo (las distribuciones de Linux cambian a menudo), o si usas una distribución que no está en la lista, discute el tema en el forum, y ayúdanos a corregirlo.



Git
La mejor manera de obtener el código es clonar el repositorio de sólo lectura Git repository. Para ello necesitas el programa que se puede instalar fácilmente en la mayoría de las distribuciones de Linux, y también se puede obtener en la sitio web oficial.

Esto colocará una copia de la última versión del código fuente de FreeCAD en un nuevo directorio llamado.

Para más información sobre el uso de Git y la contribución de código al proyecto, véase Gestión de código fuente.

Archivo Fuente
También puede descargar el código fuente como un archivo, un archivo o , y descomprimirlo en el directorio deseado.

Obtener las dependencias
Para compilar FreeCAD tienes que instalar las dependencias necesarias mencionadas en Bibliotecas de terceros; los paquetes que contienen estas dependencias están listados abajo para diferentes distribuciones de Linux. Tenga en cuenta que los nombres y la disponibilidad de las bibliotecas dependerán de su distribución particular; si su distribución es antigua, algunos paquetes pueden no estar disponibles o tener un nombre diferente. En este caso, busque en la sección Distribuciones antiguas y no convencionales más abajo.

Una vez que tengas todas las dependencias instaladas procede a compilar FreeCAD.

Ten en cuenta que el código fuente de FreeCAD tiene un tamaño de unos 500 MB; puede ser tres veces mayor si clonas el repositorio Git con todo su historial de modificaciones. Obtener todas las dependencias puede requerir la descarga de 500 MB o más de nuevos archivos; cuando estos archivos se descomprimen pueden requerir 1500 MB o más de espacio. También ten en cuenta que el proceso de compilación puede generar hasta 1500 MB de archivos adicionales ya que el sistema copia y modifica todo el código fuente. Por lo tanto, asegúrese de tener suficiente espacio libre en su disco duro, al menos 4 GB, cuando intente la compilación.

Debian y Ubuntu
En los sistemas basados en Debian (Debian, Ubuntu, Mint, etc.) es bastante fácil conseguir instalar todas las dependencias necesarias. La mayoría de las bibliotecas están disponibles a través de o del gestor de paquetes Synaptic.

Si ya has instalado FreeCAD desde los repositorios oficiales, puedes instalar sus dependencias de construcción con esta única línea de código en un terminal:

Sin embargo, si la versión de FreeCAD en los repositorios es antigua, las dependencias pueden ser las incorrectas para compilar una versión reciente de FreeCAD. Por lo tanto, comprueba que tienes instalados los siguientes paquetes.

Estos paquetes son esenciales para que cualquier tipo de compilación tenga éxito:
 * , instala los compiladores C y C++, las librerías de desarrollo C y el programa.
 * , herramienta esencial para configurar el código fuente de FreeCAD. También puedes querer instalar y  para una opción gráfica.
 * , herramientas esenciales para producir bibliotecas compartidas.
 * , la utilidad estándar de informes de base normalmente ya está instalada en un sistema Debian, y le permite distinguir mediante programación entre una instalación Debian pura o una variante, como Ubuntu o Linux Mint. No elimine este paquete, ya que muchos otros paquetes del sistema pueden depender de él.

La compilación de FreeCAD utiliza el lenguaje Python, y también se utiliza en tiempo de ejecución como lenguaje de scripting. Si estás usando una distribución basada en Debian el intérprete de Python normalmente ya está instalado.
 * , la herramienta que crea interfaces entre el código C++ y Python.
 * , la herramienta que crea interfaces entre el código C++ y Python.

Por favor, comprueba que tienes instalado Python 3. Python 2 quedó obsoleto en 2019, por lo que los nuevos desarrollos en FreeCAD no se prueban con esta versión del lenguaje.

Es necesario instalar las bibliotecas Boost:



Es necesario instalar las bibliotecas de Coin:
 * , para Debian Jessie, Stretch, Ubuntu 16.04 a 18.10, o
 * , para Debian Buster, Ubuntu 19.04 y más recientes, así como para Ubuntu 18.04/18.10 con los PPAs freecad-stable/freecad-daily añadidos a sus fuentes de software.

Varias bibliotecas que se ocupan de las matemáticas, las superficies trianguladas, la ordenación, las mallas, la visión por ordenador, las proyecciones cartográficas, la visualización 3D, el sistema de ventanas X11, el análisis sintáctico de XML y la lectura de archivos Zip:


 * or
 * or
 * or
 * or
 * or
 * or
 * or
 * or

Python 2 y Qt4
This is not recommended for newer installations as both Python 2 and Qt4 are obsolete. As of version 0.20, FreeCAD no longer supports them.

To compile FreeCAD for Debian Jessie, Stretch, Ubuntu 16.04, using Python 2 and Qt4, install the following dependencies.



Python 3 y Qt5
To compile FreeCAD for Debian Buster, Ubuntu 19.04 and newer, as well as Ubuntu 18.04/18.10 with the freecad-stable/freecad-daily PPAs added to your software sources, install the following dependencies.


 * (if compiling 0.20 on a machine that still has Qt4)
 * or
 * (if compiling 0.20 on a machine that still has Qt4)
 * or
 * or
 * or

Núcleo OpenCascade
The OpenCascade kernel is the core graphics library to create 3D shapes. It exists in an official version OCCT, and a community version OCE. The community version is no longer recommended, as it's outdated.

For Debian Buster and Ubuntu 18.10 and newer, as well as Ubuntu 18.04 with the freecad-stable/freecad-daily PPAs added to your software sources, install the official packages.



For Debian Jessie, Stretch, Ubuntu 16.04 and newer, install the community edition packages.



You may install the libraries individually, or using asterisk expansion. Change for  if you want to install the community libraries.

Paquetes opcionales
Optionally you can also install these extra packages:
 * , to make Coin support additional image file formats.
 * and (or  for older systems), if you intend to generate source code documentation.
 * , for 3D input devices support, like the 3Dconnexion "Space Navigator" or "Space Pilot".
 * , if you intend to register your installed files into your system's package manager, so you can uninstall it later.

Comando único para Python 3 y Qt5
Requires Pyside2 available in Debian buster and the freecad-stable/freecad-daily PPAs.

NOTE: On some versions of Ubuntu and some versions of Qt, you will get an error that python3-pyside2uic cannot be found -- on those systems you can safely omit it. On Ubuntu 20.04 you will need to add pyqt5-dev-tools. More information can be found in this forum discussion.

Comando único para Python 2 y Qt4
This is not recommended for newer installations as both Python 2 and Qt4 are obsolete.

Ubuntu 16.04 users please see also the compilation discussion in the forum: Compile on Linux (Kubuntu): CMake can't find VTK.

Raspberry Pi
Follow the same steps as in Debian and Ubuntu.

There are problems reported when trying to compile in Raspbian with Python 3 and Qt5, but the combination Python 3 and Qt4 seems to work for older versions of FreeCAD.

For newer versions of FreeCAD the compilation with Py3/Qt5 is successful if the operating system installed is Ubuntu 20.04.

Due to different issues with Qt, in this version the normal PySide tools won't be found.

In this case, we can install the packages from PyQt and create symbolic links to the needed tools.

Now compilation may proceed.

The option to  should not be more than 3 because the Raspberry Pi has limited memory. It will take several hours to compile, so it is better to do it overnight.

More information, FreeCAD and Raspberry Pi 4.

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
 * qt5-qtxmlpatterns
 * qt5-qttools-static
 * ode-devel
 * xerces-c
 * xerces-c-devel
 * opencv-devel
 * smesh-devel
 * Coin3
 * Coin3-devel

(Coin not to be confused with coin - a financial pkg. April 2021, Coin4 and Coin4-devel are available ) (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
 * vtk
 * med
 * med-devel

And optionally :


 * libspnav-devel (for 3Dconnexion devices support like the Space Navigator or Space Pilot)
 * python3-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
Los siguientes comandos instalarán los paquetes necesarios para construir FreeCAD con Qt5 y Python 3.

El siguiente comando instalará Qt Creator y el depurador de proyectos GNU.

Si falta algún paquete, puedes comprobar el archivo Tumbleweed "FreeCAD.spec" en el Open Build Service.

Además, compruebe si hay algún parche que deba aplicar (como 0001-find-openmpi2-include-files.patch).

Leap
Si hay una diferencia entre los paquetes disponibles en Tumbleweed y Leap, entonces puedes leer el archivo Leap "FreeCAD.spec" en el Open Build Service para determinar los paquetes necesarios.

Ver piano_jonas guía no oficial "Compilar en openSUSE".

Arch Linux
Necesitará las siguientes bibliotecas de los depósitos oficiales:


 * boost
 * curl
 * desktop-file-utils
 * glew
 * hicolor-icon-theme
 * jsoncpp
 * libspnav
 * opencascade
 * shiboken2
 * xerces-c
 * pyside2
 * python-matplotlib
 * python-netcdf4
 * qt5-svg
 * qt5-webkit
 * qt5-webengine
 * cmake
 * eigen
 * git
 * gcc-fortran
 * pyside2-tools
 * swig
 * qt5-tools
 * shared-mime-info
 * coin
 * python-pivy
 * med

Distribuciones antiguas y no convencionales
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 in your package manager. Beware that some of them might have a slightly different package name; search for, but also , , , and similar. If that is not possible try compiling those libraries yourself.

FreeCAD requires the GNU g++ compiler version equal or above 3.0.0, as FreeCAD is mostly written in C++. During the compilation some Python scripts are executed, so the Python interpreter has to work properly. To avoid any linker problems it is also a good idea to have the library paths in the variable or in the  file. This is already done in modern Linux distributions, but may need to be set in older ones.

Pivy
Pivy (Python wrappers to Coin3d) is not needed to build FreeCAD or to start it, but it is needed as a runtime dependency by the Draft Workbench. If you are not going to use this workbench, you won't need Pivy. However, do notice that the Draft Workbench is used internally by other workbenches, like Arch and BIM, so Pivy needs to be installed to use these workbenches as well.

By November 2015 the obsolete version of Pivy included with the FreeCAD source code will no longer compile on many systems. This isn't a big problem as normally you should get Pivy from your distribution's package manager; if you cannot find Pivy, you may have to compile it yourself, see Pivy compilation instructions.

Símbolos de depuración
In order to troubleshoot crashes in FreeCAD, it is useful to have the debug symbols of important dependency libraries such as Qt. For this, try installing the dependency packages that end with, , or similar, depending on your Linux distribution.

For Ubuntu, you may have to enable especial repositories to be able to see and install these debug packages with the package manager. See Debug Symbol Packages for more information.

Compila FreeCAD
FreeCAD utiliza CMake como su principal sistema de compilación, ya que está disponible en los principales sistemas operativos. La compilación con CMake es normalmente muy simple y ocurre en dos pasos.


 * 1) CMake comprueba que todos los programas y bibliotecas necesarios están presentes en tu sistema, y genera un  que se configura para el segundo paso. FreeCAD tiene varias opciones de configuración entre las que elegir, pero viene con unos valores por defecto razonables. Algunas alternativas se detallan a continuación.
 * 2) La compilación propiamente dicha, que se realiza con el programa, que genera los ejecutables de FreeCAD.

Dado que FreeCAD es una aplicación de gran tamaño, la compilación de todo el código fuente puede tardar entre 10 minutos y una hora, dependiendo de tu CPU y del número de núcleos de la CPU utilizados para la compilación.

Puedes construir el código dentro o fuera del directorio de origen. La construcción fuera de la fuente es generalmente la mejor opción.

Creación-fuera-fuente
Building in a separate folder is more convenient than building in the same directory where the source code is located as every time you update the source code CMake can intelligently determine which files have changed, and recompile only what is needed. This is very useful when testing different Git branches as you don't confuse the build system.

To build out-of-source, simply create a build directory,, distinct from your FreeCAD source folder, ; then from this build directory point to the right source folder. You can use or  instead of  in the instructions below as well. Once finishes configuring the environment, use  to start the actual compilation.

Note: if you are compiling the 0.19 release branch, you must explicitly specify that you are compiling with Qt5 and Python 3 -- replace the cMake command above with:

The option of  controls how many jobs (files) are compiled in parallel. The program prints the number of CPU cores in your system; by using it together with the  option you can choose to process as many files as you have cores, in order to speed up overall compilation of the program. In the example above, it will use all cores in your system except two; this will keep your computer responsive for other uses while compilation proceeds in the background. The FreeCAD executable will eventually appear in the directory. See also Compiling (speeding up) to improve compilation speed.

Creación interna fuentes
In-source builds are fine if you want to compile a version of FreeCAD quickly, and don't intend to update the source code often. In this case, you can remove the compiled program and the source just by deleting a single folder.

Change to the source directory, and point to the present directory (denoted by a single point):

The FreeCAD executable will then reside in the directory.

Cómo reparar su directorio de código fuente
If you accidentally performed a compilation inside the source code directory, or added strange files, and would like to restore the contents to only the original source code, you can perform the following steps.

The first line clears the 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. The second line deletes all files and directories that are not tracked by the git repository; then the last command will reset any changes to tracked files, including the first command which cleared the file.

If you do not clear the source directory, subsequent runs of may not capture new options to the system if the code changes.

Configuración
By passing different options to, you can change how FreeCAD is compiled. The syntax is as follows.

Where is the directory that contains the source code. The may be omitted in most cases. The space after the option may also be omitted.

For example, to avoid building the FEM Workbench:

All possible variables are listed in the file, located in the  directory. In this file, search for the word to get to the variables that can be set, and see their default values.


 * 1) =================   All the options for the build process    =================
 * 1) =================   All the options for the build process    =================

option(BUILD_FORCE_DIRECTORY "The build directory must be different to the source directory." OFF) option(BUILD_GUI "Build FreeCAD Gui. Otherwise you have only the command line and the Python import module." ON) option(FREECAD_USE_EXTERNAL_ZIPIOS "Use system installed zipios++ instead of the bundled." OFF) option(FREECAD_USE_EXTERNAL_SMESH "Use system installed smesh instead of the bundled." OFF) ...

Alternatively, use the command to list the current configuration, and thus all variables that can be changed. You may also install and use to launch a graphical interface showing all the variables that can be modified. In the next sections we list some of the more relevant options that you may want to use.

Para una creación de depuración
Create a build to troubleshoot crashes in FreeCAD. Beware that with this build the Sketcher becomes very slow with complex sketches.

Para una creación de versión
Create a build to test code that doesn't crash. A build will run much faster than a  build.

Creación contra Python 3 y Qt5
By default, FreeCAD 0.19 and earlier build for Python 2 and Qt4. Since these two packages are obsolete, it is better to build for Python 3 and Qt5. Support for Python 2 and Qt4 has been removed in FreeCAD 0.20 and it is not necessary to explicitly enable Qt5 and Python 3 if compiling the latest development versions.

In a modern Linux distribution you only need to provide two variables specifying the use of Qt5, and the path to the Python interpreter.

Por 0.19:

Por 0.20_dev:

Note that when switching between 0.19 and the 0.20 builds, it may be necessary to delete CMakeCache.txt prior to running cmake.

Creación para una versión específica de Python
If the default executable in your system is a symbolic link to Python 2,  will try to configure FreeCAD for this version. You can choose another version of Python by giving the path to a specific executable:

If that doesn't work, you may have to define additional variables pointing to the desired Python libraries and include directories:

It is possible to have several independent versions of Python in the same system, so the locations and version numbers of your Python files will depend on your particular Linux distribution. Use to display the version of Python that you are using currently; only the first two numbers are necessary; for example, if the result is, you need to specify the directories that relate to the 3.6 version. If you don't know the right directories, try searching for them with the command.

You may use in a terminal to determine the  directory, or  for Debian systems.

Creación con Qt Creator contra Python 3 y Qt5
1. Launch Qt Creator.

2. Click on.

3. Navigate to the directory where the source code is,, and choose the topmost file.

4. By selecting the file, it will automatically run on it, but it may fail if the appropriate options aren't correctly set.

5. Go to. Set the appropriate build directory,.

6. Set the appropriate variables in the Key-Value dialog, of types and.

7. If the variables do not load the project correctly, you may have to go to. Then press, and add the appropriate configuration as described above. You may have to add more variables about the Python paths, if the system Python is not found.

7.1. Press, then.

7.2. Make sure the rest of the options are correctly set, for example, should be a present version installed in the system, like.

Press, then to close the configuration.

The program should run automatically again, and it should fill the entire Key-Value dialog with all the variables that can be configured.

8. Go to and choose  to compile the graphical version of FreeCAD, or  to compile only the command line version.

9. Finally, go to the menu. If this is a new compilation, it should take several minutes, inclusive hours, depending on the number of processors that you have available.

Qt designer complemento
If you want to develop Qt code for FreeCAD, you'll need the Qt Designer plugin that provides all custom widgets of FreeCAD.

Go into an auxiliary directory of the source code, the run with the indicated project file to create a ; then run  to compile the plugin.

If you are compiling for Qt5, make sure the binary is the one for this version, so that the resulting  contains the necessary information for Qt5.

where is the directory that stores Qt binary libraries, for example,.

The library created is, which needs to be copied to.

Pivy externo o interno
Previously, a version of Pivy was included in the source code of FreeCAD (internal). If you wanted to use your system's copy of Pivy (external), you needed to use.

Using external Pivy became the default during development of FreeCAD 0.16, therefore this option does not need to be set manually anymore.

Documentación de Doxygen
If you have Doxygen installed you can build the source code documentation. See source documentation for instructions.

Documentación adicional
The source code of FreeCAD is very extensive, and with CMake it's possible to configure many options. Learning to use CMake fully may be useful to choose the right options for your particular needs.
 * CMake Reference Documentation by Kitware.
 * How to Build a CMake-Based Project (blog) by Preshing on programming.
 * Learn CMake's Scripting Language in 15 Minutes (blog) by Preshing on programming.

Hacer un paquete debian
Si planea construir un paquete Debian a partir de las fuentes, necesita instalar primero ciertos paquetes:

Vaya al directorio de FreeCAD y llame a

Una vez construido el paquete, puede utilizar para comprobar si el paquete contiene errores

Actualización del código fuente
The CMake system allows you to intelligently update the source code, and only recompile what has changed, making subsequent compilations faster.

Move to the location where the FreeCAD source code was first downloaded, and pull the new code:

Then move into the build directory where the code was compiled initially, and run specifying the present directory (denoted by a dot); then trigger the re-compilation with.

Para sistemas de 64 bits
When building FreeCAD for 64-bit there is a known issue with the OpenCASCADE (OCCT) 64-bit package. To get FreeCAD running properly you might need to run the script and set additional :

For Debian based systems this option is not needed when using the pre-built OpenCASCADE packages because these ones set the proper internally.

Scripts de creación automática
Here is all what you need for a complete build of FreeCAD. It's a one-script-approach and works on a freshly installed Linux distribution. The commands will ask for the root password for installation of packages and new online repositories. 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 distribution, please discuss it on the FreeCAD forum so we can incorporate it.

Ubuntu
Estos scripts proporcionan una forma fiable de instalar el conjunto correcto de dependencias necesarias para construir y ejecutar FreeCAD en Ubuntu. Hacen uso de los archivos de paquetes personales de Ubuntu (PPA), y deberían funcionar en cualquier versión de Ubuntu a la que se dirija el PPA. El freecad-daily PPA se dirige a versiones recientes de Ubuntu, mientras que el freecad-stable PPA se dirige a las versiones oficialmente soportadas de Ubuntu.

This script installs the daily compiled snapshot of FreeCAD and its dependencies. It adds the daily repository, gets the dependencies to build this version, and installs the required packages. Afterwards it proceeds to pull the source code into a particular directory, creates a build directory and changes into it, configures the compilation environment with, and finally builds the entire program with. Save the script to a file, make it executable, and run it, but don't use ; superuser privileges will be asked only for selected commands.

If you wish, you can uninstall the pre-compiled version of FreeCAD while leaving the dependencies in place, however, leaving this package installed will allow the package manager to keep its dependencies up to date as well; this is mostly useful if you intend to follow the development of FreeCAD, and constantly update and compile the sources from the Git repository.

The previous script assumes that you want to compile the latest version of FreeCAD, so you are using the "daily" repository to get the dependencies. However, you can instead get the build dependencies of the "stable" version for your current Ubuntu release. If this is the case, replace the top part of the previous script with the following instructions. For Ubuntu 12.04, omit from the command.

Once you install the package from the  repository, it will supersede the FreeCAD executable that is available from the Universe Ubuntu repository. The executable will be named simply, and not.

OpenSUSE 12.2 = ¡¡¡Descartado!!!
No external Repositories are needed to compile FreeCAD. However, there is an imcompatability with python3-devel which needs to be removed. FreeCAD can be compiled from GIT

Como estás usando git, la próxima vez que desees compilar no tienes que clonar todo, simplemente tira de git y compila una vez más

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

Arch usando AUR
Arch User Repository (AUR) is a collection user made recipes to build packages which are not officially supported by distribution maintainers / community. They are usually safe. You can see who maintain the package and for how long he did. It is recommended to check construction files. Also non open source software are available in this area even if maintained by the official owning company.

Requisito previo : git

Steps :
 * 1) Open a terminal. Optionally create a directory eg. . Optionally change directory eg..
 * 2) Clone the AUR repository :
 * 3) Enter AUR repository folder :
 * 4) Compile using Arch makepkg : . The -s or --syncdeps flag will also install required dependencies.
 * 5) Install created package : or double click on the pkgname-pkgver.pkg.tar.xz inside your file browser.

To update FreeCAD to latest build just repeat from step 3. Update AUR repo when there is some breaking change in the recipe or new features using inside the folder.