CompileOnUnix

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 or packages that FreeCAD depends on
 * 3) Configure with  and compile with

Below, you'll find detailed explanations of the whole process, some build scripts, and particularities you might encounter. If you find anything wrong or out of date in the text below (Linux distributions change often), or if you use a distribution which is not listed, discuss the issue in the forum, and help us correct it.



Git
The best way to get the code is to clone the read-only Git repository. For this you need the program which can be easily installed in most Linux distributions, and it can also be obtained from the official website.

This will place a copy of the latest version of the FreeCAD source code in a new directory called.

For more information on using Git, and contributing code to the project, see Source code management.

Source archive
Alternatively you can download the source as an archive, a or  file, and unpack it in the desired directory.

Getting the dependencies
To compile FreeCAD you have to install the requisite dependencies mentioned in Third Party Libraries; the packages that contain these dependencies are listed below for different Linux distributions. Please note that the names and availability of the libraries will depend on your particular distribution; if your distribution is old, some packages may be unavailable of have a different name. In this case, look in the older and non-conventional distributions section below.

Once you have all the dependencies installed proceed to compile FreeCAD.

Please note that FreeCAD's source code is around 500 MB in size; it may be three times as big if you clone the Git repository with its entire modification history. Getting all dependencies may require downloading 500 MB or more of new files; when these files are unpacked they may require 1500 MB or more in space. Also beware that the compilation process may generate up to 1500 MB of additional files as the system copies and modifies the entire source code. Therefore, be sure you have enough free space in your hard drive, at least 4 GB, when attempting compilation.

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 or the 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:

However, if the version of FreeCAD in the repositories is old, the dependencies may be the wrong ones to compile a recent version of FreeCAD. Therefore, please verify that you have installed the following packages.

These packages are essential for any sort of compilation to succeed:
 * , installs the C and C++ compilers, the C development libraries, and the program.
 * , essential tool to configure the source of FreeCAD. You may also wish to install and  for a graphical option.
 * , essential tools to produce shared libraries.
 * , the standard base reporting utility is normally already installed in a Debian system, and allows you to programmatically distinguish between a pure Debian installation or a variant, such as Ubuntu or Linux Mint. Do not remove this package, as many other system packages may depend on it.

Compilation of FreeCAD uses the Python language, and it's also used at runtime as a scripting language. If you are using a Debian based distribution the Python interpreter is normally already installed.
 * , the tool that creates interfaces between C++ code and Python.
 * , the tool that creates interfaces between C++ code and Python.

Please check that you have Python 3 installed. Python 2 was obsoleted in 2019, so new development in FreeCAD is not tested with this version of the language.

The Boost libraries need to be installed:

The Coin libraries need to be installed:
 * , for Debian Jessie, Stretch, Ubuntu 16.04 to 18.10, or
 * , for Debian Buster, Ubuntu 19.04 and newer, as well as for Ubuntu 18.04/18.10 with the freecad-stable/freecad-daily PPAs added to your software sources.

Several libraries that deal with mathematics, triangulated surfaces, sorting, meshes, computer vision, cartographic projections, 3D visualization, the X11 Window system, XML parsing, and Zip file reading:
 * or
 * or
 * or
 * or
 * or
 * or
 * or
 * or

Python 2 and Qt4
This is not recommended for newer installations as both Python 2 and Qt4 are obsolete. To compile FreeCAD for Debian Jessie, Stretch, Ubuntu 16.04, using Python 2 and Qt4, install the following dependencies.

Python 3 and 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.
 * or
 * or
 * or
 * or
 * or

OpenCascade kernel
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.

Optional packages
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 3Dconnexion devices support, like the 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.

Single command for Python 3 and Qt5
Requires Pyside2 available in Debian buster and the freecad-stable/freecad-daily PPAs.

Single command for Python 2 and 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.

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
 * desktop-file-utils
 * glew
 * hicolor-icon-theme
 * jsoncpp
 * libspnav
 * med
 * opencascade
 * shiboken2
 * xerces-c
 * pyside2
 * python-matplotlib
 * python-netcdf4
 * qt5-svg
 * qt5-webkit
 * qt5-webengine
 * boost
 * cmake
 * eigen
 * git
 * gcc-fortran
 * pyside2-tools
 * swig
 * qt5-tools
 * shared-mime-info

Also, make sure to check the AUR for any missing packages that are not on the repositories, currently:
 * coin
 * python-pivy
 * med

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

Compile FreeCAD
FreeCAD uses CMake as its main build system, as it's 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 generates a  that is configured 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 is done with the program, which generates the FreeCAD executables.

Since FreeCAD is a large application, compiling the entire source code can take anywhere from 10 minutes to one hour, depending on your CPU and the number of CPU cores used for compilation.

You can build the code either in or out of the source directory. Out-of-source building is generally the best option.

Out-of-source build
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.

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.

In-source building
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.

How to repair your source code directory after accidentally running an in-source build
If you accidentally performed a compilation inside the source code directory, 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.

Configuration
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 toplevel  directory. In this file, search for the word to get to the variables that can be set, and see their default values.

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.

For a Debug build
Create a build to troubleshoot crashes in FreeCAD. Beware that with this build the Sketcher becomes very slow with complex sketches.

For a Release build
Create a build to test code that doesn't crash. A build will run much faster than a  build.

Building against Python 3 and Qt5
By default, FreeCAD builds for Python 2 and Qt4. Since these two packages are obsolete, it is better to build for Python 3 and Qt5.

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

Building for a specific Python version
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.

Building with Qt Creator against Python 3 and Qt5
To compile in Qt Creator add the appropriate variables to the bottom of. Again, specify the correct paths and Python version that you want to use.

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

Qt designer plugin
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.

The library created is, which needs to be copied to , where is the directory that stores Qt binary libraries.

External or internal Pivy
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.

Doxygen documentation
If you have Doxygen installed you can build the source code documentation. See source documentation for instructions.

Additional documentation
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.

Making a debian package
If you plan to build a Debian package out of the sources you need to install certain packages first:

Go to the FreeCAD directory and call

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

Updating the source code
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.

For 64 bit systems
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.

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 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
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 Ubuntu personal package archives (PPA), and should work on any version of Ubuntu targeted by the PPA. The freecad-daily PPA targets recent versions of Ubuntu, while the freecad-stable PPA targets officially supported versions of 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
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

Arch using 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.

Prerequisite : 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.