Build from source
- 1 Building LibreCAD 2.0 on Linux
- 2 Installing Linux and building LibreCad on android devices in a Linux chroot environment
- 3 Building LibreCAD 2.0 on Windows
- 4 Building LibreCAD-2.0 on OS/X
Building LibreCAD 2.0 on Linux
Detailed steps can be found at Build in Linux
Installing Linux and building LibreCad on android devices in a Linux chroot environment
Detailed steps are here: 
Building LibreCAD 2.0 on Windows
To build LibreCAD from the lastest development version, you will need tools: git, Qt, boost and muParser. You also will need NSIS for creating installer.
The ways to get LibreCAD source code in Windows are described at .
If you are planning to contribute, don't edit the librecad.pro, build-windows.bat and nsis-5.3.nsi files to fit your local settings. This would result in changes for git you have to care about in each commit, pull and push. Instead create the files custom.pro, custom-windows.bat and custom.nsh, which are ignored by git, and set your local settings there.
Download Qt from : Qt download. Offline installer with MinGW should be used instead of the Windows online installer. Qt-5.3.2 for Windows 32 bit (MinGW 4.8) is used as an example in this article.
Install Qt (including Qt-Creator) to C:\Qt\Qt5.3.2\ (the default path prompted by Qt installer). The MinGW tools will be in C:\Qt\Qt5.3.2\Tools\mingw482_32\bin\ by default.
Introduction for boost can be found here boost introduction.
Download boost 1.53 from: boost download. Do not try version 1.54, 1.55 or 1.56 (there are compilation errors as of 12 Oct 2014).
unzip the boost files to the directory: C:\boost\ , and for the version boost-1.53.0, the boost files will be located in C:\boost\boost_1_53_0\ .
Verify that you have the file C:\boost\boost_1_53_0\booststrap.bat. You don't have to build boost in order to build LibreCAD, as LibreCAD uses header only part of boost currently.
within the LibreCAD source folder, edit the custom.pro file accordingly,
BOOST_DIR = C:/boost/boost_1_53_0/ BOOST_LIBDIR = C:/boost/boost_1_53_0/
On Windows, muParser is not required to build LibreCAD since LibreCAD-2.0.4, as LibreCAD uses by default a patched version of muParser included within LibreCAD source.
muParser is at muParser.
Building LibreCAD in Qt-Creator
Launch Qt-Creator and open the librecad.pro project file within the LibreCAD source folder. Accept Qt path detected by Qt-Creator by clicking "Configure Project" button, if the project is not configured yet.
Take care about the Shadow build option in Debug and Release configuration. Disable this option in both configurations and save the project.
Select librecad as building target in Qt Creator (instead of tff2lff, which is another choice)
If everything is good up to this point, you can build and run LibreCAD within Qt-Creator.
Building Windows by command line
A command line building script file is added as scripts/build-windows.bat. To be able to use this batch file, you need to have your Qt and NSIS directories set up first. Default values for Qt_Dir, MINGW_VER and NSIS_DIR are set in file scripts/set-windows-env.bat:
set Qt_DIR=C:\Qt\Qt5.3.2\5.3 set NSIS_DIR=C:\Program Files (x86)\NSIS set MINGW_VER=mingw482_32
To change these default settings you have to create the file scripts/custom-windows.bat and overwrite the different settings without effect to the SCM (git).
Example for scripts/custom-windows.bat:
set Qt_DIR=D:\files\local\Qt\Qt5.3.2\5.3 set MINGW_VER=mingw482_32 set NSIS_DIR=C:\Program Files\NSIS
There are issues with the NSIS_DIR path on 64 Bit Windows. When NSIS is installed in the Program Files (x86) folder and NSIS_DIR is added to the PATH, something goes wrong in the build process.
In this case use the command dir /X \ and get an output like this:
09/02/2014 09:50 PM <DIR> PROGRA~1 Program Files 10/27/2014 12:33 PM <DIR> PROGRA~2 Program Files (x86) 08/16/2014 10:49 PM <DIR> Qt
You need the short name of the Program Files (x86) folder. With that information set NSIS_DIR like following in scripts/custom-windows.bat to avoid the issues:
To start building, go to the scripts/ folder within the LibreCAD source folder from Windows command prompt
run the build-windows.bat
The last step of build-windows.bat is calling NSIS to create the LibreCAD-Installer.exe.
If everything was OK, the installer can be found in the generated/ folder within LibreCAD source folder.
Building Windows Installer by NSIS
By default, LibreCAD uses NSIS to generate installers in Windows.
If you would like to build an installer for Windows, you will need the tool. You can use the lastest NSIS version.
You need to setup your Qt_Dir, Mingw_Ver and Qt_Version in the scripts\postprocess-windows\custom.nsh file if they don't match the default settings in scripts\postprocess-windows\nsis-5.3.nsi.
Example for scripts\postprocess-windows\custom.nsh:
!define Qt_Dir "C:\Qt\Qt5.3.2" !define Qt_Version "5.3" !define Mingw_Ver "mingw482_32"
These settings indicate Qt-5.3.2 is installed at C:\Qt\Qt5.3.2\5.3\ and it comes with Qt-Creator in C:\Qt\Qt5.3.2\Tools\QtCreator\ and qmake.exe in C:\Qt\Qt5.3.2\5.3\mingw482_32\bin\
If you use an other Qt Version, e.g. Qt 5.2, where the master branch default is Qt 5.3.x, you have to use scripts\postprocess-windows\nsis-5.2.nsi for building the installer package.
Then you have to add this line to scripts/custom-windows.bat:
This line tells the build-win-setup.bat script to use nsis-5.2.nsi instead of nsis-5.3.nsi, which is currently default setting on master branch.
Building Windows installer
If you build LibreCAD by command line(Start run: cmd.exe or powershell) as in the previous section, the windows installer is created automatically by the build-windows.bat.
cd scripts .\build-windows.bat
When LibreCAD Release version was build from Qt Creator, use build-win-setup.bat to create the windows installer.
To start building of windows installer, start windows command prompt and go to the LibreCAD source folder. Then type/copy/paste this:
cd scripts .\build-win-setup.bat
If everything runs smoothly, you should have the installer file as,
Building LibreCAD-2.0 on OS/X
LibreCAD in MacPorts
To install LibreCAD by MacPorts:
Optional, update package list
$ sudo port selfupdate
Install the LibreCAD package
$ sudo port install librecad
Following steps describe steps to build LibreCAD manually.
Alternative: Building from Downloaded Source Code
Install QT and a new gcc, which should be version 4.7 or later (gcc-4.8 is recommended).
Install a version of Qt, boost and muparser, for example
$ sudo port install gcc48 qt4-creator-mac qt4-mac boost freetype
Again, if you are running an OS/X version older than Mavericks(10.9), you may have to select gcc-4.8 as the default compiler:
$ sudo port select gcc
Accept gcc48 as the current active gcc.
Please note LibreCAD uses a patched version muparser, and the muparser package from MacPorts is not a required dependency any more.
Get Latest LibreCAD Source Code
To test the latest LibreCAD version, you may clone the official repository, and this cloning only needs to be done once. The latest development version of LibreCAD-2.0 is the master branch.
Alternatively, you may download source code zipballs/tarballs from github: https://github.com/LibreCAD/LibreCAD/releases
$ sudo port install git-core $ mkdir -p ~/github $ cd ~/github $ git clone https://github.com/LibreCAD/LibreCAD.git
The last git command will clone the official LibreCAD repository to a folder ~/github/LibreCAD/ If you have a previous cloned repository, say, in ~/github/LibreCAD/ , you can update the code by:
$ cd ~/github/LibreCAD/ $ git fetch origin $ git checkout master $ git rebase origin/master
To be able to rely on pkg-config to find libraries, you may add the following to custom.pro
$ echo "QT_CONFIG -= no-pkg-config" >> custom.pro
Select the right compiler
LibreCAD doesn't build with the default llvm-gcc42. For example you may choose gcc48 by:
$ sudo port install gcc48 $ sudo port select --set gcc mp-gcc48
On OS/X 10.9 or newer, use spec macx-g++ is the default. Alternatively, you may use the system default clang++ compiler instead of gcc。
$ qmake librecad.pro -r -spec macx-g++
On OS/X version 10.8 or older, run the following command to build a makefile in the LibreCAD source folder (as in our example, ~/github/LibreCAD/ )
$ qmake librecad.pro -r -spec mkspec/macports
If the previous step is successful, you can build LibreCAD by issuing:
$ make -j4
After a successful build, the generated executible of LibreCAD can be found as
By the building script
Alternatively, you may try the building script comes with LibreCAD at scripts/build-osx.sh to build an DMG file. On OS/X 10.9 or newer,
$ cd ~/github/LibreCAD/ $ cd scripts/ $ ./build-osx.sh
On OS/X 10.8 or older, you may have to edit the build-osx.sh to qmake command lines like:
qmake -r -spec mkspec/macports
to use the qmake mkspec shipped within LibreCAD source code.