CompileOnUnix

From FreeCAD Documentation
Jump to: navigation, search
This page is a translated version of the page CompileOnUnix and the translation is 12% complete.

Outdated translations are marked like this.
Other languages:
български • ‎čeština • ‎Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎polski • ‎português • ‎português do Brasil • ‎română • ‎русский • ‎svenska • ‎Türkçe • ‎中文(中国大陆)‎

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):

git clone https://github.com/FreeCAD/FreeCAD.git freecad-code

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)

Github

Siempre hay un repositorio actualizado de FreeCAD en Gihub:

github.com/FreeCAD/FreeCAD

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.

  • build-essential
  • cmake
  • python
  • python-matplotlib
  • libtool

either:

  • libcoin60-dev (Debian Wheezy, Wheezy-backports, Ubuntu 13.04 and before)

or:

  • libcoin80-dev (Debian unstable(Jesse), testing, Ubuntu 13.10 and forward)
  • libsoqt4-dev
  • libxerces-c-dev
  • libboost-dev
  • libboost-filesystem-dev
  • libboost-regex-dev
  • libboost-program-options-dev
  • libboost-signals-dev
  • libboost-thread-dev
  • libboost-python-dev
  • libqt4-dev
  • libqt4-opengl-dev
  • qt4-dev-tools
  • python-dev
  • python-pyside
  • pyside-tools

either:

  • libopencascade-dev (official opencascade version)

or:

  • liboce*-dev (opencascade community edition)
  • oce-draw
  • libeigen3-dev
  • libqtwebkit-dev
  • libshiboken-dev
  • libpyside-dev
  • libode-dev
  • swig
  • libzipios++-dev
  • libfreetype6
  • libfreetype6-dev

Additional instruction for libcoin80-dev Debian wheezy-backports, unstable, testing, Ubuntu 13.10 and forward

Note that liboce*-dev includes the following libraries:

  • liboce-foundation-dev
  • liboce-modeling-dev
  • liboce-ocaf-dev
  • liboce-visualization-dev
  • liboce-ocaf-lite-dev

You may have to install these packages by individual name.

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 yo can easily uninstall later)
  • python-pivy (needed for the 2D Drafting module)
  • python-qt4 (needed for the 2D Drafting module)
  • doxygen and libcoin60-doc (if you intend to generate source code documentation)
  • libspnav-dev (for 3Dconnexion devices support like the Space Navigator or Space Pilot)


sudo apt install build-essential cmake python python-matplotlib libtool libcoin80-dev libsoqt4-dev libxerces-c-dev libboost-dev libboost-filesystem-dev libboost-regex-dev libboost-program-options-dev libboost-signals-dev libboost-thread-dev libboost-python-dev libqt4-dev libqt4-opengl-dev qt4-dev-tools python-dev python-pyside pyside-tools libeigen3-dev libqtwebkit-dev libshiboken-dev libpyside-dev libode-dev swig libzipios++-dev libfreetype6-dev liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev libsimage-dev checkinstall python-pivy python-qt4 doxygen libspnav-dev oce-draw liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-ocaf-lite-dev liboce-visualization-dev libmedc-dev libvtk6-dev libproj-dev

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 :

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.

OpenSUSE

You need the following packages:

  • gcc
  • cmake
  • OpenCASCADE-devel
  • libXerces-c-devel
  • python-devel
  • libqt4-devel
  • libshiboken-devel
  • python-pyside-devel
  • python-pyside-tools
  • Coin-devel
  • SoQt-devel
  • boost-devel
  • libode-devel
  • libQtWebKit-devel
  • libeigen3-devel
  • gcc-fortran
  • freetype2
  • freetype2-devel
  • Eigen3
  • swig

For FreeCAD 0.14 stable and 0.15 unstable, if Eigen3 and swig libraries are not found in standard repos, you can get them with a one-click install here:

Also, note that the Eigen3 Library from Factory Education was causing problems sometimes, so use the one from the KDE 4.8 Extra repo

Starting with 0.17pre Opensuse 13.2 is too old to build due to too old boost.

Arch Linux

You will need the following libraries from the official repositories:

  • boost-libs
  • curl
  • hicolor-icon-theme
  • libspnav
  • opencascade
  • python2-pivy
  • python2-matplotlib
  • python2-pyside
  • python2-shiboken
  • qtwebkit
  • shared-mime-info
  • xerces-c
  • boost
  • cmake
  • coin
  • 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:

  • python2-pyside-tools
  • med (Modelisation et Echanges de Donnees)
sudo pacman -S boost-libs curl hicolor-icon-theme libspnav opencascade python2-pivy python2-matplotlib python2-pyside python2-shiboken qtwebkit shared-mime-info xerces-c boost cmake coin desktop-file-utils eigen gcc-fortran med python2-pyside-tools

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

Utilizando cMake

cMake es un nuevo sistema de construcción que tiene la gran ventaja de ser común en diferentes sistemas (Linux, Windows, MacOSX, etc). FreeCAD está utilizando el sistema cMake como el sistema principal de construcción. Compilar con cMake es usualmente simple y sucede en dos pasos. En el primero, cMake revisa que todos los programas y librerías estén presentes en tu sistema y prepara todo lo necesario para la compilación subsecuente. Te son dadas algunas alternativas detalladas debajo, pero FreeCAD trae consigo defaults sensibles. El segundo paso es la compilación misma, la cual produce el ejecutable FreeCAD.

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)

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:

$ cd freecad (the folder where you cloned the freecad source)

Si instalaste pivy desde la fuente, indica al compilador que utilice el pivy correcto (vía FREECAD_USE_EXTERNAL_PIVY=1). También, pon el modo de construcción en debug. (NOTA: el "." y espacio después de las instrucciones cmake son CRÍTICAS):


 $ cmake -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Debug .
 $ make
 
For a Debug build
$ cmake -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Debug .
# Note: to speed up build use all CPU cores: make -j$(nproc)
$ make
Or for a Release build
$ cmake -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Release .
# Note: to speed up build use all CPU cores: make -j$(nproc)
$ make

Tu ejecutable FreeCAD residirá entonces en la carpeta "bin", y podrás ejecutarlo con: $ ./bin/FreeCAD

$ ./bin/FreeCAD

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.

1) delete everything in your source base directory EXCEPT the hidden .git folder
2) In terminal 'git reset --hard HEAD'
//any remnants of an 'in source' build will be gone.
3) delete everything from your 'out of source' build directory and start over again with cmake and a full new clean build.

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:

mkdir freecad-build
cd freecad-build
cmake ../freecad-code (or whatever the path is to your FreeCAD source folder)
# Note: to speed up build use all CPU cores: make -j$(nproc)
make

El ejecutable FreeCAD residirá en el directorio "bin" (dentro de tu directorio de construcción).

Configuration options

There are a number of experimental or unfinished modules you may have to build if you want to work on them. To do so, you need to set the proper options for the configuration phase. Do it either on the command line, passing -D <var>:<type>=<value> options to cMake or using one of the availables gui-frontends (eg for Debian, packages cmake-qt-gui or cmake-curses-gui). Changing any options for cmake away from their default values, is much easier with cmake-gui or other graphical cmake applications than with cmake on the command line, as they will give you interactive feed back.

As an example, to configure FreeCAD with the Assembly module built just tick the box in a cmake gui application (e.g. cmake-gui) or on the command line issue:

cmake -D FREECAD_BUILD_ASSEMBLY:BOOL=ON ''path-to-freecad-root''

Possible options are listed in FreeCAD's root CmakeLists.txt file.

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

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

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:

dh-make
devscripts

#optional, used for checking if packages are standard-compliant
lintian

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

#replace by the name of the package you just created
lintian your-fresh-new-freecad-package.deb

Troubleshooting

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.

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.

#!/bin/sh
sudo add-apt-repository --enable-source ppa:freecad-maintainers/freecad-daily && sudo apt-get update
# Install the dependencies needed to build FreeCAD
sudo apt-get build-dep freecad-daily
# Install the dependencies needed to run FreeCAD (and a build of FreeCAD itself)
sudo apt-get install freecad-daily

This script installs dependencies for the latest stable release of FreeCAD. (For Ubuntu 12.04, omit "--enable-source" from the add-apt-repository command.)

#!/bin/sh
sudo add-apt-repository --enable-source ppa:freecad-maintainers/freecad-stable && sudo apt-get update
# Install the dependencies needed to build FreeCAD
sudo apt-get build-dep freecad
# Install the dependencies needed to run FreeCAD (and a build of FreeCAD itself)
sudo apt-get install freecad

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

#!/bin/sh

# checkout the latest source
git clone https://github.com/FreeCAD/FreeCAD.git freecad

# go to source dir
cd freecad

# open cmake-gui window
cmake-gui .

# build configuration
cmake .

# build FreeCAD
# Note: to speed up build use all CPU cores: make -j$(nproc)
make

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

# install needed packages for development
sudo zypper install gcc cmake OpenCASCADE-devel libXerces-c-devel \
python-devel libqt4-devel python-qt4 Coin-devel SoQt-devel boost-devel \
libode-devel libQtWebKit-devel libeigen3-devel gcc-fortran git swig
 
# create new dir, and go into it
mkdir FreeCAD-Compiled 
cd FreeCAD-Compiled
 
# get the source
git clone https://github.com/FreeCAD/FreeCAD.git free-cad
 
# Now you will have subfolder in this location called free-cad. It contains the source
 
# make another dir for compilation, and go into it
mkdir FreeCAD-Build1
cd FreeCAD-Build1 
 
# build configuration 
cmake ../free-cad
 
# build FreeCAD
make
 
# test FreeCAD
cd bin
./FreeCAD -t 0

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

# go into free-cad dir created earlier
cd free-cad
 
# pull
git pull
 
# get back to previous dir
cd ..
 
# Now repeat last few steps from before.
 
# make another dir for compilation, and go into it
mkdir FreeCAD-Build2
cd FreeCAD-Build2
 
# build configuration 
cmake ../free-cad
 
# build FreeCAD
# Note: to speed up build use all CPU cores: make -j$(nproc)
make
 
# test FreeCAD
cd bin
./FreeCAD -t 0

Debian Squeeze

# get the needed tools and libs
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 gfortran
 
# checkout the latest source
git clone https://github.com/FreeCAD/FreeCAD.git freecad
 
# go to source dir
cd freecad
 
# build configuration 
cmake .
 
# build FreeCAD
# Note: to speed up build use all CPU cores: make -j$(nproc)
make
 
# test FreeCAD
cd bin
./FreeCAD -t 0

Fedora 22/23/24

Posted by user [PrzemoF] in the forum.

#!/bin/bash

#ARCH=x86_64
#ARCH=i686
ARCH=$(arch)

MAIN_DIR=FreeCAD
BUILD_DIR=build

#FEDORA_VERSION=22
FEDORA_VERSION=23
#FEDORA_VERSION=24

echo "Installing packages required to build FreeCAD"
sudo dnf -y install gcc cmake gcc-c++ boost-devel zlib-devel swig eigen3 qt-devel \
shiboken shiboken-devel pyside-tools python-pyside python-pyside-devel xerces-c \
xerces-c-devel OCE-devel smesh graphviz python-pivy python-matplotlib tbb-devel \
 freeimage-devel Coin3 Coin3-devel med-devel vtk-devel

cd ~

mkdir $MAIN_DIR || { echo "~/$MAIN_DIR already exist. Quitting.."; exit; }

cd $MAIN_DIR

git clone https://github.com/FreeCAD/FreeCAD.git

mkdir $BUILD_DIR || { echo "~/$BUILD_DIR already exist. Quitting.."; exit; }

cd $BUILD_DIR

cmake ../FreeCAD 

# Note: to speed up build use all CPU cores: make -j$(nproc)
make

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:

#Replace with the location where you cloned the source code the first time
cd freecad-code
#If you are using git
git pull

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:

#Replace with the location of the build directory
cd ../freecad-build
cmake .
# to use all cpu cores change to: make -j$(nproc)
make

Links

See also Compiling - Speeding up How to speed up compilation

< Anterior: CompileOnWindows/es
Siguiente: CompileOnMac/es >