CompileOnUnix

On recent linux distributions, FreeCAD is generally easy to build, since all dependencies are usually provided by the package manager. Basically, you'll just need to get the FreeCAD source, then install the dependencies listed below, then issue: ./autogen.sh && ./configure && make or ./cmake. && make to get FreeCAD built, depending on what build system you prefer to use (autotools or cmake). Below, you'll find detailed explanations of the whole process and particularities you might encounter. Before you get too bogged down in details, there is also a shellscript that you can use to follow along. If you find anything wrong in it or here below, please help us correcting it.

Getting the source
Before you can compile FreeCAD, you must get the source code. First install subversion. Then, from the directory of your choice (for example your user directory), do: svn co https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk freecad This will perform an anonymous checkout of the current development version in a new directory called "freecad". Alternatively you can download a source tarball but they could be already quite old so it's probably better to always get the latest sources via subversion. Note, though, that the subversion version is the FreeCAD version currently being worked on, and it might contain bugs or even fail to compile.

Prerequisites
To compile FreeCAD under Linux you have to install all libraries mentioned in Third Party Libraries first. 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++. Both gcc and g++ are included in the build-essential package listed below. 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 would be 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.

Debian/Ubuntu and most recent distributions
On Debian based systems it is quite easy to get all needed dependencies installed. Most of the libraries are available via apt-get or synaptic package manager. Below are listed all packgages you need to install. On other distributions, the package names can vary, but usually you'll be able to find them all too: build-essential python libcoin60-dev libsoqt4-dev libxerces-c2-dev (or libxerces28-dev depending on your system) 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 (or higher version if available) libopencascade-dev

To simply install all these libraries in one step, just copy/paste the following text in a terminal (only for debian/ubuntu based systems) as root: aptitude 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 libopencascade-dev

optionally you can also install libsimage-dev (to make Coin to support additinal 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)

Older and non-conventional distributions
On older distributions, however you might not find the following libraries:

OpenCASCADE
Not all Linux distributions have an official OpenCASCADE package in their repositories. You have to check yourself for your distribution if one is available. At least from Debian Lenny and Ubuntu Intrepid on an official .deb package is provided. For older Debian or Ubuntu releases you may get unofficial packages from here. To build your own private .deb packages follow these steps:

wget http://lyre.mit.edu/~powell/opencascade/opencascade_6.2.0.orig.tar.gz wget http://lyre.mit.edu/~powell/opencascade/opencascade_6.2.0-7.dsc wget http://lyre.mit.edu/~powell/opencascade/opencascade_6.2.0-7.diff.gz

dpkg-source -x opencascade_6.2.0-7.dsc

sudo apt-get install build-essential devscripts debhelper autoconf automake libtool bison libx11-dev tcl8.4-dev tk8.4-dev libgl1-mesa-dev libglu1-mesa-dev java-gcj-compat-dev libxmu-dev
 * 1) Install OCC build-deps

cd opencascade-6.2.0 ; debuild
 * 1) Build Opencascade packages. This takes hours and requires
 * 2) at least 8 GB of free disk space

sudo dpkg -i libopencascade6.2-0_6.2.0-7_i386.deb libopencascade6.2-dev_6.2.0-7_i386.deb
 * 1) Install the resulting library debs

Alternatively, you can download and compile the latest version from opencascade.org:

Install the package normally, be aware that the installer is a java program that requires the official java runtime edition from Sun (package name: sun-java6-jre), not the open-source java (gij) that is bundled with Ubuntu. Install it if needed: sudo apt-get remove gij sudo apt-get install sun-java6-jre Be careful, if you use gij java with other things like a browser plugin, they won't work anymore. If the installer doesn't work, try: java -cp path_to_file_setup.jar <-Dtemp.dir=path_to_tmp_directory> run

Once the package is installed, go into the "ros" directory inside the opencascade dir, and do ./configure --with-tcl=/usr/lib/tcl8.4 --with-tk=/usr/lib/tk8.4 Now you can build. Go back to the ros folder and do: make It will take a long time, maybe several hours.

When it is done, just install by doing sudo make install The library files will be copied into /usr/local/lib which is fine because there they will be found automatically by any program. Alternatively, you can also do sudo checkinstall which will do the same as make install but create an entry in your package management system so you can easily uninstall later. Now clean up the enormous temporary compilation files by doing make clean

Possible error 1: If you are using OCC version 6.2, it is likely that the compiler will stop right after the beginning of the "make" operation. If it happens, edit the "configure" script, locate the CXXFLAGS="$CXXFLAGS " statement, and replace it by CXXFLAGS="$CXXFLAGS -ffriend-injection -fpermissive". Then do the configure step again.

Possible error 2: Possibly several modules (WOKSH, WOKLibs, TKWOKTcl, TKViewerTest and TKDraw) will complain that they couldn't find the tcl/tk headers. In that case, since the option is not offered in the configure script, you will have to edit manually the makefile of each of those modules: Go into adm/make and into each of the bad modules folders. Edit the Makefile, and locate the lines CSF_TclLibs_INCLUDES = -I/usr/include and CSF_TclTkLibs_INCLUDES = -I/usr/include and add /tcl8.4 and /tk8.4 to it so they read: CSF_TclLibs_INCLUDES = -I/usr/include/tcl8.4 and CSF_TclTkLibs_INCLUDES = -I/usr/include/tk8.4

SoQt
The SoQt library must be compiled against Qt4, which is the case in most recent distributions. But at the time of writing this article there were only SoQt4 packages for Debian itself available but not for all Ubuntu versions. To get the packages built do the following steps:

wget http://ftp.de.debian.org/debian/pool/main/s/soqt/soqt_1.4.1.orig.tar.gz wget http://ftp.de.debian.org/debian/pool/main/s/soqt/soqt_1.4.1-6.dsc wget http://ftp.de.debian.org/debian/pool/main/s/soqt/soqt_1.4.1-6.diff.gz dpkg-source -x soqt_1.4.1-6.dsc sudo apt-get install doxygen devscripts fakeroot debhelper libqt3-mt-dev qt3-dev-tools libqt4-opengl-dev cd soqt-1.4.1 debuild sudo dpkg -i libsoqt4-20_1.4.1-6_i386.deb libsoqt4-dev_1.4.1-6_i386.deb libsoqt-dev-common_1.4.1-6_i386.deb

If you are on a 64bit system, you will probably need to change i386 by amd64.

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. At the time of writing, Pivy is very new and might not have made its way into your distribution repository. You can grab debian/ubuntu packages on the FreeCAD download page:

http://sourceforge.net/projects/free-cad/files/FreeCAD%20Linux/

or compile pivy yourself:

Pivy compilation instructions

The autotools way
You must have automake and libtool installed on your system; on Debian/Ubuntu: aptitude install automake libtool If you got the sources with subversion then the very first step must be ./autogen.sh that creates the configure script and more. For the build process itself we provide a configure script. Just type ./configure To get everything configured. If you want an overview of all options you can specify, you can type ./configure --help. Normally you need none of them - unless you have one of your libraries installed in a really uncommon directory. After configuration has finished, compiling FreeCAD is as simple as make If any error occurs while building from sources, please double-check this page and README.Linux file, then you could jump to the Bug Tracker on SourceForge, choose Any for status and click the Browse button to see previous reports on compile problems. After having built FreeCAD successfully, do make install to install it onto your machine. The default install directory is ~/FreeCAD It will be installed in a FreeCAD folder in your home folder, so you don't need root privileges. Instead of make install, you can also do checkinstall In this way FreeCAD will be installed by your package management system, so you can uninstall it easily later. But since all of FreeCAD installation resides into one single directory, just removing the FreeCAD directory is a valid way to uninstall too.

The cMake way
cMake is a newer build system which has the big advantage of being common for different target systems (Linux, Windows, MacOSX, etc). FreeCAD is progressively switching to the cMake system, and you can already build FreeCAD in that way. Assuming cMake is installed on your system, switch to your FreeCAD source folder, and issue: cmake. To have the source configured, then make To have FreeCAD built. A proper system-wide installation of FreeCAD still cannot be made with cmake, but you can run FreeCAD simply by issuing ,/bin/FreeCAD

Optional parts
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

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.

Automake macros
The configure script of FreeCAD makes use of several automake macros that are sometimes not installed with their packages: bnv_have_qt.m4, coin.m4, and gts.m4. If needed (error while configuring), google for them and you will find them easily. They are just simple scripts that you need to put in your /usr/share/aclocal folder.

Making a debian package
If you plan to build a Debian package out of the sources you need to install those packages first: dh-make devscripts lintian (optional, used for checking if packages are standard-compliant) To build a package open a console, simply go to the FreeCAD directory and call debuild Once the package is built, you can use lintian to check if the package contains errors lintian your-fresh-new-freecad-package.deb (replace by the name of the package you just created)

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. This scripts should run on 32 and 64 bit versions. They are written for distinct version, but are also likely to run on a later version with or without minor changes.

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

Ubuntu 9.10 - Karmic Koala
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.6-dev libopencascade-dev libsoqt4-dev \ libode-dev subversion cmake libeigen2-dev libsimage-dev python-qt4 \ libtool autotools-dev automake bison flex svn co https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk freecad cd freecad cmake. make cd bin ./FreeCAD -t 0
 * 1) checkout the latest source
 * 1) go to source dir
 * 1) build configuration
 * 1) build FreeCAD
 * 1) test FreeCAD

Ubuntu 9.04 - Jaunty Jackalope
sudo apt-get install build-essential python libcoin40-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.6-dev \ libsimage-dev libopencascade-dev \ libsoqt4-dev libode0-dev subversion cmake libeigen2-dev python-pivy \ libtool autotools-dev automake svn co https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk freecad cd freecad cmake. make cd bin ./FreeCAD -t 0
 * 1) get the needed tools and libs
 * 1) checkout the latest source
 * 1) go to source dir
 * 1) build configuration
 * 1) build FreeCAD
 * 1) test FreeCAD

OpenSuse 11.2
This script is not working at the moment because:
 * libXerces-c-devel seams to be disappeared ....

sudo zypper install gcc cmake subversion OpenCASCADE-devel \ libXerces-c-devel python-devel libqt4-devel python-qt4 \ Coin-devel SoQt-devel boost-devel libode-devel libQtWebKit-devel \ libeigen2-devel svn co https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk freecad cd freecad cmake. nice make cd bin ./FreeCAD -t 0
 * 1) install needed packages for development
 * 1) get the source
 * 1) go to source dir
 * 1) build configuration
 * 1) build FreeCAD
 * 1) test FreeCAD

OpenSuse 11.1
sudo zypper -p http://packman.unixheads.com/suse/11.1/ sudo zypper install gcc cmake subversion OpenCASCADE-devel \ libXerces-c-devel python-devel libqt4-devel python-qt4 \ Coin-devel SoQt-devel boost-devel libode-devel libQtWebKit-devel \ libeigen2-devel svn co https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk freecad cd freecad cmake. nice make cd bin ./FreeCAD -t 0
 * 1) additional repository (for OpenCascade)
 * 1) install needed packages for development
 * 1) get the source
 * 1) go to source dir
 * 1) build configuration
 * 1) build FreeCAD
 * 1) test FreeCAD

Debian Squeeze
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 svn co https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk freecad cd freecad cmake. make cd bin ./FreeCAD -t 0
 * 1) get the needed tools and libs
 * 1) checkout the latest source
 * 1) go to source dir
 * 1) build configuration
 * 1) build FreeCAD
 * 1) test FreeCAD