Updating local source

Qt

Download Qt from : Qt download. Offline installer with MinGW is recommended instead of the Windows online installer. Qt-5.4.1 for Windows 32 bit (MinGW 4.9.1) is used as an example in this article.

Install Qt (including Qt-Creator) to C:\Qt\5.4\ (the default path prompted by Qt installer). The MinGW tools will be in C:\Qt\5.4\mingw491_32\bin by default.

muParser

On Windows, muParser is not required to build LibreCAD since LibreCAD-2.0.4, because LibreCAD uses by default a patched version of muParser included within LibreCAD source.

Custom files

If you are planning to contribute, don't edit the librecad.pro, build-windows.bat and nsis-5.4.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.

custom-windows.bat

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=C:\Qt\5.4
set NSIS_DIR=C:\PROGRA~2\NSIS
set MINGW_VER=mingw491_32

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:

custom.nsh

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.4.nsi.
Example for scripts\postprocess-windows\custom.nsh:

These settings indicate Qt-5.4 is installed at C:\Qt\5.4 and it comes with Qt-Creator in C:\Qt\Tools\QtCreator and qmake.exe in C:\Qt\5.4\mingw491_32\bin

If you use an other Qt Version, e.g. Qt 5.4, where the master branch default is Qt 5.3.x, you have to use scripts\postprocess-windows\nsis-5.4.nsi for building the installer package.
Then you have to add this line to scripts/custom-windows.bat:

set LC_NSIS_FILE=nsis-5.4.nsi

This line tells the build-win-setup.bat script to use nsis-5.4.nsi instead of nsis-5.3.nsi, which is currently default setting on master branch.

Building Windows installer

press the windows-key and type qt

select Qt 5.4 for desktop

input: cd "C:\librecad\scripts" (or where ever your local source is)

input: 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 (LibreCAD-installer.exe) can be found in the generated folder within LibreCAD source folder.

(When LibreCAD Release version was built from Qt Creator, use build-win-setup.bat to create the windows installer.)

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.

Note that adding -j to the make arguments can significantly improve build time.