Build from source - LibreCAD/LibreCAD GitHub Wiki

Both wikis need updating; therefore, it is recommended that you also check:
http://wiki.librecad.org/index.php/Build_from_source

If you want to become a developer you will also want to read:
https://github.com/LibreCAD/LibreCAD/wiki/Becoming-a-developer

Clone the repository

If you will be making changes to the code:
https://github.com/LibreCAD/LibreCAD/wiki/Git-and-GitHub

If you will not be making changes to the code:

  1. create a folder for repositories
  2. open a terminal
  3. cd repositories_folder
  4. git clone https://github.com/LibreCAD/LibreCAD.git

When you want to update:

  1. open a terminal
  2. cd cloned_repository_folder
  3. git pull -r

Table of Contents

  1. Debian, Ubuntu and other derivatives
  2. openSUSE
  3. Red Hat and similar distributions
  4. FreeBSD
  5. Windows
  6. Generic Unix
  7. macOS

Debian, Ubuntu and other derivatives

Make sure you have the Qt development packages installed. To install Qt version 5, run the following commands:

$ sudo apt-get install g++ gcc make git-core qtbase5-dev libqt5svg5-dev\
 qttools5-dev qtchooser qttools5-dev-tools libmuparser-dev librsvg2-bin\
 libboost-dev libfreetype6-dev libicu-dev pkg-config qt5-default

You also have to either install the qt5-default package (apt-get install qt5-default) or use qtchooser prior to running qmake (e.g., qtchooser -qt5).

After the installation of dependency packages, download the LibreCAD source from the official LibreCAD repository, and run the following commands in the top folder of the downloaded LibreCAD source code:

qmake -r
make

as described in section Generic Unix Users.

openSUSE

  • zypper in boost-devel freeglut-devel gcc make
  • zypper in libqt5-qtbase-devel libqt5-qtbase-common-devel
  • zypper in libQt5Core5 libQt5Gui5 libQt5PrintSupport5 libQt5Svg5 libQt5Widgets5
  • zypper in libQt5Core-devel libQt5Gui-devel libQt5PrintSupport-devel libqt5-qtsvg-devel libQt5Widgets-devel
cd path_to_local_repository
qmake-qt5 -r
make

If you want to use Qt Creator:

  • zypper in libqt5-creator
  • open librecad.pro
  • accept the default configuration
  • go to the 'Projects' side tab
  • choose the 'release' or 'debug' configuration, and uncheck 'Shadow build'
  • optional: add -j or -j3 to the make arguments to improve build speed
  • make sure the 'run configuration' is on src (as opposed to ttf2lff)
  • Build -> Run (or the big green triangle at the bottom left)

You can look at the official openSUSE librecad.spec file for more information.

Red Hat and similar distributions

Install Qt, Boost and muParser development packages for your respective distribution; EPEL and similar repositories may come handy if your base OS does not include the necessary packages.

As an example, for CentOS 6.4, after adding the EPEL repository,

yum groupinstall 'Desktop Platform Development' 'Development tools'
yum install qt-devel boost-devel muParser-devel
yum builddep librecad

will install the necessary build dependencies.

Building of LibreCAD in Red Hat is similar to the building procedure described in the [Ubuntu](#Users of Ubuntu/Debian and derivatives) section.

FreeBSD

  • Building with Qt version5:
  • Install
databases/qt5-sql devel/qt5-core devel/qt5-help graphics/qt5-svg math/muparser
net/qt5-network print/qt5-printsupport textproc/clucene-qt5 x11-toolkits/qt5-gui
x11-toolkits/qt5-widgets
  • Run
/usr/local/lib/qt5/bin/qmake QMAKE_CXXFLAGS="-I /usr/local/include" QMAKE_LIBS="-L /usr/local/lib" && make
  • Building with Qt version 4:
  • Install
databases/qt4-sql devel/qt4-corelib devel/qt4-help graphics/qt4-svg math/muparser
net/qt4-network textproc/clucene-qt4 x11-toolkits/qt4-gui
  • Run
qmake-qt4 -r && make

The executable is generated at unix/librecad

Windows

Building steps are also given at our wiki page:

LibreCAD Installation from Source

A sample build batch file is included as scripts/build-windows.bat. If successful, this building script generates a Windows installer file using NSIS.

Start Qt Creator and load LibreCAD.pro, from the build menu select "Build All".

Visual Studio 2013+

  • Follow all of the instructions for building LibreCAD 2.0 on Windows. The steps for "Building LibreCAD in Qt-Creator" may be omitted.
  • Install the appropriate Qt Visual Studio Tools plugin for your version of Visual Studio.
  • RTFM. Set it up.
  • Qt VS Tools > Open Qt Project File > librecad.pro
  • Build

Any future changes needed for the Visual Studio project files, should instead be made in the Qt .pro project files. If you are planning to contribute, please do not check any of the Visual Studio project files in. They will contain the personalized settings from your "custom.pro".

Windows Building from Command Line

scripts/build-windows.bat batch file for automatic building is supplied. Read Building Windows by command line for more details.

Generic Unix

Install necessary dependecy: Qt, boost, muParser (see http://wiki.librecad.org for details).

Unzip or checkout a version of LibreCAD into a directory LibreCAD.

cd LibreCAD
qmake -r librecad.pro
make

The executable is generated at unix/librecad

macOS

Homebrew (with LLVM)

Install the latest versions of boost and qt5 from Homebrew.

brew install boost qt5

Clone the LibreCAD repository and change to its directory.

git clone https://github.com/LibreCAD/LibreCAD
cd LibreCAD

Run qmake. Note that during the installation step above (brew install qt5), the binaries have not been linked to /usr/local, so in order to use qmake, you can either

  • use the full path (e.g. /usr/local/Cellar/qt5/5.7.0/bin/qmake), or
  • run brew link qt5 --force, which will allow you to simply write qmake at the prompt.
qmake librecad.pro -r -spec macx-clang

Now you are ready to build the application.

make -j4

If the previous step did not result in any errors, you should now have an application named LibreCAD.app in your build directory. You can run it by typing either

  • open LibreCAD.app, or
  • LibreCAD.app/Contents/MacOS/LibreCAD.

Homebrew (with GCC)

Install Homebrew from http://brew.sh/.

gcc --version # you'll need gcc 4.4 or newer. If yours is older:
brew tap homebrew/versions
brew options gcc48
brew install [flags] gcc48
mkdir ~/bin
cd ~/bin
ln -s /usr/local/bin/gcc-4.8 gcc
ln -s /usr/local/bin/g++-4.8 g++
ln -s /usr/local/bin/gcc-ar-4.8 gcc-ar
ln -s /usr/local/bin/gcc-nm-4.8 gcc-nm
ln -s /usr/local/bin/gcc-ranlib-4.8 gcc-ranlib
source ~/.bashrc
gcc --version # make sure it's 4.8, as installed and configured in the previous step. if it's not, ~/bin might not be on your path
brew install boost qt5

Unzip or checkout a version of LibreCAD into a directory.

cd LibreCAD

Run the following command:

./scripts/build-osx.sh

If the ./qmake directory cannot be found, run this command first:

brew link qt5 --force

This creates an executable "LibreCAD.app/Contents/MacOS/LibreCAD" and package "LibreCAD.dmg".

MacPorts

install MacPorts from http://www.macports.org/

You can install LibreCad using MacPorts by: $ sudo port install librecad

You can build LibreCAD manually by following steps:

Install QT and a new gcc, which should have a version 4.4 or later.

Install a version of Qt and boost, for example $ sudo port install gcc46 qt5-creator qt5 boost

Select the right compiler, as LibreCAD doesn't build with the default llvm-gcc42, $ sudo port select --set gcc mp-gcc46

Unzip or checkout a version of LibreCAD into a directory.

cd LibreCAD
./scripts/build-osx.sh

This creates an executable "LibreCAD.app/Contents/MacOS/LibreCAD" and package "LibreCAD.dmg".