We have moved to https://dokuwiki.librecad.org/

Lots of content was already moved to the new wiki, but there is still work to do. If you want to contribute, please register a new account at https://dokuwiki.librecad.org/

This wiki will be kept for a while to keep search engine results valid. Moved sites may be deleted here in future.

Build from source

From LibreCAD wiki
Revision as of 01:39, 7 July 2013 by Dli (Talk | contribs)

Jump to: navigation, search

Building LibreCAD 2.0 on Windows

To build LibreCAD from the lastest development version, you will need tools: git , Qt, boost, and muParser.

The ways to get LibreCAD source code in Windows are described at [1].

If you are planning to contribute, don't edit the librecad.pro and build-windows.bat 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 and custom-windows.bat, which are ignored by git, and set your local settings there.


Download Qt from : Qt download. Qt-5.0.1 for Windows 32 bit (MinGW 4.7) is used as an example in this article.

Install Qt (including Qt-Creator) to \Qt\Qt5.0.1\ (Assuming you install everything to C:\ , the same assumption thereafter)

Install the MinGW tools are at: \Qt\Qt5.0.1\Tools\MinGW\bin\


Introduction for boost can be found here boost introduction.

Download boost from: boost download.

unzip the boost files to the directory: \boost\ , and for the version boost-1.53.0, the boost files will be located in \boost\boost_1_53_0\ .

Verify that you have the file \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 settings_windows.pro file accordingly,

   BOOST_DIR = /boost/boost_1_53_0/
   BOOST_LIBDIR = /boost/boost_1_53_0/


muParser is at muParser.

Download muParser source from: muParser Download

unzip the muParser source files to \muparser\muparser_v2_2_3 (for muParser-2.2.3).

Steps to build muParser with MinGW:

run DOS prompt as Administrator (Start->All Programs->Accessories->Command Prompt , right click and choose "Run as administrator") in DOS prompt, type in:

   set PATH=C:\Qt\Qt5.0.1\Tools\MinGW\bin;%PATH%
   cd \muparser\muparser_v2_2_3\build
   C:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe -f makefile.mingw

muParser should build smoothly.

within the LibreCAD source folder, edit the settings_windows.pro file accordingly,

   MUPARSER_DIR = /muparser/muparser_v2_2_3

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.

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. In the file scripts/build-windows.bat, a default Qt_Dir and NSIS_DIR is set:

   set Qt_DIR=C:\Qt\Qt5.0.2\5.0.2
   set NSIS_DIR=C:\Program Files (x86)\NSIS

and if you point Qt_DIR to the folder where you have installed your Qt to. You should have the Qt/MinGW tools at:


If these default settings doesn't fit your local settings you have the option to create the file scripts/custom-windows.bat and overwrite one or both settings without effect to the SCM (git).
Example for scripts/custom-windows.bat:

   set Qt_DIR=D:\Qt\Qt5.0.2\5.0.2
   set NSIS_DIR=C:\Program Files\NSIS

To start building, go to the scripts/ folder within the LibreCAD source folder from Windows command prompt

   cd scripts

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

If you would like to build an installer for Windows, you will need the tool NSIS.

You need to setup Qt_Dir and Qt_Version in the scripts\postprocess-windows\nsis-5.0.nsi file.

   !define Qt_Dir "C:\Qt"
   !define Qt_Version "5.0.2"

These settings indicate Qt-5.0.2 is installed at C:\Qt\Qt5.0.2\5.0.2\ and it comes with Qt-Creator at C:\Qt\Qt5.0.2\Tools\QtCreator\

If you build LibreCAD by command line as in the previous section, the windows installer is created automatically by the 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, go to the scripts/ folder within LibreCAD source folder, and run the batch file build-win-setup.bat.

If everything runs smoothly, you should have the installer file as,



Install dependecies

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

After that install QT and a new gcc, which should be version 4.4 or later

Install a version of Qt, boost and muparser, for example

   $ sudo port install gcc46 qt4-creator-mac qt4-mac boost muparser

Select the right compiler

LibreCAD doesn't build with the default llvm-gcc42. For example you may choose gcc46 by:

   $ sudo port select --set gcc mp-gcc46

Run the following command to build a makefile in the LibreCAD source folder

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

   $ cd scripts/
   $ ./build-osx.sh