CompileOnUnix

Compile on Linux
Before you get too bogged down in details, here is a script that you can use to follow along: DebianScript

If you find anything wrong, please correct it.

Get Source
Before you compile FreeCAD, you must get the source code. First install subversion. Then, in the appropriate directory, do: svn co https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk freecad This will give you an anonymous checkout of the current development version in a new directory "freecad".

Prerequisites
To compile FreeCAD under Linux you have to install all libraries mentioned in Third Party Libraries first. As compiler you should have installed gcc in a version newer than 3.x.y.

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.

During the compilation some Python scripts get executed. So the Python interpreter has to work properly.

For more details have also a look to README.Linux in your sources.

First of all you should build the Qt plugin that provides all custom widgets of FreeCAD we need for the Qt Designer. The sources are located under //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 your Qt Designer you have to copy the file to //$QTDIR/plugin/designer//.

Configuration
For the build process of FreeCAD we provide a configure script. Just type in ./configure --help to get an overview of all options you can specify. Normally you need none of them - unless you have one of your libraries installed in a really uncommon directory. After configuration has finished type make into your console.

If any bugs 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.

Installation
After having built FreeCAD successfully, with a simple make install you can install it onto your machine.The default install directory is /home/ /FreeCAD so you don't need root privileges therefore.

Compile on Ubuntu 64 bits
Compiling on a 64-bit machine is a bit tricky but it works fine. This explanation assumes you can download from a svn repository, install ubuntu packages and that you know how to cope with the maybe necessary permissions/sudo/chown stuff. Also, read the first part here above first.

Pre-compiled Libraries / Ubuntu packages
You need all the FreeCAD Third Party Libraries correctly installed before compiling, and also a few other libraries needed by OpenCascade, like tcl/tk. Most of the libraries are availible via apt-get or synaptic package manager. You probably have several of them already installed... For most of them you need the library and its "dev" package which contains files used when you compile your own programs: python libqt3 libqt3-dev libcoin40c2 libcoin40-dev libsoqt20 libsoqt-dev libxerces27 libxerces27-dev libgts-0.7-1 libgts-dev tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev libboost*

The last one, the boost library, is not provided as a single package, but in several (about 20) small packages. If you use synaptic, mark all packages that begin with "libboost".

As you see, several of those libraries have their version number in the package name. Those are the most recent versions at the time I am writing this. So maybe you can find more recent versions, which should work too. An exception to this is QT, at this moment only qt3 is supported by FreeCAD, not qt4. But you can have both qt3 and qt4 libraries installed...

Libraries you need to compile yourself

 * WildMagic3

Since FreeCAD 0.7 the Wildemagic code is incorporated in the FreeCAD source. You only need to compile WildeMagic3 if you use prior 0.7!

At the time I write this, only Wildmagic version 3 is supported by FreeCAD. On the Wildmagic site, you can download a 3.XX version. Unpack it somewhere and go into the Foundation folder. This contains the base libraries, which are all you need to compile.

First you need to make a small change, which seems to be needed by many programs to work in 64 bits: Edit the makeprj.lnx file and locate the CFLAGS := -c line. Add -fPIC so it reads: CFLAGS := -c -fPIC Then compile it with make -f makefile.lnx If it gives you some error about mkdir, edit the makefile.lnx and delete these three lines: @mkdir ../Include @mkdir ../Library/$(CONFIG) @mkdir $(CONFIG) At the end, in your Wildmagic3 folder, you will have new "Include" and "Library" folders, which you will use when compiling freeCAD. Clean the temporary compile stuff by doing make -f makefile.lnx clean


 * OpenCASCADE

This is a bit more difficult. The package you download from opencascade.org contains 32bit-compiled libraries, which we won't use, and the sources, which we will use. Before anything, be aware that you will need several (>7) Gigabytes free at the moment you compile.

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 path_where_you_installed_opencascade/ros

EDIT: 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, come back here, edit the "configure" script, locate the CXXFLAGS="$CXXFLAGS " statement, and replace it by CXXFLAGS="$CXXFLAGS -ffriend-injection -fpermissive". Then do all the following steps again.

Now execute ./configure --with-tcl=/usr/lib/tcl8.4 --with-tk=/usr/lib/tk8.4 If you start building now, 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 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. Now clean up the enormous temporary compilation files by doing make clean

As an alternative, if you don't like to "make install" things in your well maintained ubuntu system, there are programs (checkinstall, for exemple) that will create a .deb package while installing, so you can uninstall it easily later.

Automake macros
The configure script of FreeCAD makes use of several automake macros that seem not to be installed with their packages: bnv_have_qt.m4, coin.m4, and gts.m4. If needed, 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

Compile FreeCAD
The new qt4 port is not working under Linux yet at the time I write this, so we will build the Version-0-6 that lies in the "branches" folder. Go there, then go to the Tools/plugin/widget folder and build the widget as described in the CompileOnUnix section. Copy it in /usr/libs/kde3/plugin/designer. Then all we have to do is to go back in the Version-0-6 folder, and deploy your armies: ./autogen.sh This will create the configure script, then automake This will create the Makefile templates Then, just run configure with ./configure --with-OCC-includes=PATH_TO_OPENCASCADE/ros/inc --with-OCC-libs=/usr/local/lib --with-wildmagic-includes=PATH_TO_WildMagic3/Include --with-wildmagic-libs=PATH_TO_WildMagic3/Library Then, if the configure script didn't complain about anything, do make and if all went successfully, make install Your program will be waiting in Your_home_folder/FreeCAD/bin. If you really need, you can now delete the opencascade folder, since the libraries are in /usr/local/lib, and the wildmagic one, since its library got included in FreeCAD. But I would recommend to keep it, for compiling again in the future, when new versions of FreeCAD will come out...