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.

Difference between revisions of "Build from source"

From LibreCAD wiki
Jump to: navigation, search
(Building LibreCAD-2.0 on OS/X)
(46 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
== Git and GitHub ==
 +
 +
https://github.com/LibreCAD/LibreCAD/wiki/Git-and-GitHub
 +
 
== Building LibreCAD 2.0 on Linux ==
 
== Building LibreCAD 2.0 on Linux ==
Detailed steps can be found at [http://librecad.org/cms/home/from-source/linux.html Build in Linux]
 
  
== Building LibreCAD 2.0 on Windows ==
+
=== Install dependencies ===
  
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.
+
First gather the required packages:
  
The ways to get LibreCAD source code in Windows are described at [http://librecad.org/cms/home/from-source/windows.html].
+
    $ 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
  
If you are planning to contribute, don't edit the '''librecad.pro''', '''build-windows.bat''' and '''nsis-5.1.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-5.1.nsh''', which are ignored by git, and set your local settings there.
+
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").
 +
==== If you have not cloned the LibreCAD repository ====
  
=== Qt ===
+
If you have a local LibreCAD repository, continue to [[#Update a local LibreCAD repository|Update a local LibreCAD repository]] instead
  
Download Qt from : [http://qt-project.org/downloads Qt download]. Qt-5.1.1 for Windows 32 bit (MinGW 4.8) is used as an example in this article.
+
If ~/develop does not exist, create this folder
  
Install Qt (including Qt-Creator) to '''C:\Qt\Qt5.1.1\''' (the default path by Qt installer). The MinGW tools will be in '''C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\''' by default.
+
    $ mkdir -p ~/develop/LibreCAD
  
=== boost ===
+
Clone the LibreCAD repository, please note this is needed only once
  
Introduction for boost can be found here [http://www.boost.org/doc/libs/1_53_0/more/getting_started/windows.html boost introduction].
+
    $ cd ~/develop/
 +
    $ git clone https://github.com/LibreCAD/LibreCAD.git
  
Download boost 1.53 from: [http://www.boost.org/users/download/ boost download]. Do not try version '''1.54''' or '''1.55''' (there are compilation errors on 11 Nov 2013).
+
==== Update a local LibreCAD repository ====
  
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\''' .
+
    $ cd ~/develop/LibreCAD/
 +
    $ git checkout master
 +
    $ git pull -r
  
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.
+
=== Build LibreCAD ===
  
within the LibreCAD source folder, edit the '''custom.pro''' file accordingly,
+
    $ qmake -r
 +
    $ make -j4
  
    BOOST_DIR = C:/boost/boost_1_53_0/
+
if building is successful, the generated executable is at ./unix/librecad, and you may launch LibreCAD:
    BOOST_LIBDIR = C:/boost/boost_1_53_0/
+
  
=== muParser ===
+
    $ ./unix/librecad &
  
muParser is at [http://muparser.beltoforion.de/ muParser].
+
== Installing Linux and building LibreCad on android devices in a Linux chroot environment ==
 +
Detailed steps are here:  [http://wiki.librecad.org/index.php/LibreCAD_wiki_talk:Community_portal]
  
Download muParser source from: [http://sourceforge.net/projects/muparser/files/muparser/ muParser Download]
+
== Building LibreCAD 2.0 on Windows ==
  
unzip the muParser source files to C:\muparser\muparser_v2_2_3 (for muParser-2.2.3).
+
=== Cloning the source package ===
  
Steps to build muParser with MinGW:
+
To clone LibreCAD source code by command line:
  
run DOS prompt as Administrator (Start->All Programs->Accessories->Command Prompt , right click and choose "Run as administrator")
+
    git clone https://github.com/LibreCAD/LibreCAD.git
in DOS prompt, type in:
+
  
    set PATH=C:\Qt\Qt5.1.1\Tools\MinGW48_32\bin;%PATH%
+
On Windows, you may alternatively:
    cd C:\muparser\muparser_v2_2_3\build
+
    C:\Qt\Qt5.1.1\Tools\MinGW48_32\bin\mingw32-make.exe -f makefile.mingw
+
  
muParser should build smoothly.
+
* download and install [http://msysgit.github.io/ msysgit]
 +
* press the windows-key and then type git
 +
* select "Git GUI"
 +
* after the program loads select "Clone existing repository"
 +
** enter source location: <nowiki>git://github.com/LibreCAD/LibreCAD.git</nowiki>
 +
** enter target directory: where you want the project on your hard drive
 +
* press clone and then wait for it to download
  
within the LibreCAD source folder, edit the '''custom.pro''' file accordingly,
+
=== Updating local source ===
  
    MUPARSER_DIR = C:/muparser/muparser_v2_2_3
+
* press the windows-key and then type git
 +
* select "Git Bash"
 +
* input: cd /c/your_project_folder
 +
* input: git pull -r
  
=== Building LibreCAD in Qt-Creator ===
+
=== Qt ===
  
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.
+
Download Qt from : [http://www.qt.io/download-open-source 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.
  
Take care about the '''Shadow build''' option in ''Debug'' and ''Release'' configuration. Disable this option in both configurations and save the project.
+
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.
  
If everything is good up to this point, you can build and run LibreCAD within Qt-Creator.
+
=== muParser ===
 +
 
 +
On Windows, [http://muparser.beltoforion.de/ 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 only care about building with Qt Creator, then you only need to read the boost and custom.pro section.
 +
The other custom files are for when you want to create an installer.
 +
 
 +
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.
 +
 
 +
==== boost and custom.pro ====
 +
 
 +
Download boost from: [http://www.boost.org/users/download/ boost download].
 +
 
 +
Unzip the boost files to the directory: '''C:\boost\''' -- the extracted folder would be: '''C:\boost\boost_1_60_0\''' .
 +
 
 +
Verify that you have the file '''C:\boost\boost_1_60_0\booststrap.bat'''. You don't have to build boost in order to build LibreCAD, because LibreCAD only uses headers.
 +
 
 +
In librecad/src edit the '''custom.pro''' (or custom.pri) file accordingly :
 +
 
 +
    BOOST_DIR = C:/boost/boost_1_60_0/
 +
    BOOST_LIBDIR = C:/boost/boost_1_60_0/
  
=== Building Windows by command line ===
+
==== custom-windows.bat ====
  
 
A command line building script file is added as '''scripts/build-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 '''Qt_Dir''' and '''NSIS_DIR''' are set in file '''scripts/set-windows-env.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.1.1\5.1.1
+
     set Qt_DIR=C:\Qt\Qt5.3.2\5.3
 
     set NSIS_DIR=C:\Program Files (x86)\NSIS
 
     set NSIS_DIR=C:\Program Files (x86)\NSIS
     set MINGW_VER=mingw48_32
+
     set MINGW_VER=mingw482_32
  
To change these default settings you have to create the file '''scripts/custom-windows.bat''' and overwrite one or both settings without effect to the SCM (git).<br />
+
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).<br />
 
Example for '''scripts/custom-windows.bat''':
 
Example for '''scripts/custom-windows.bat''':
  
     set Qt_DIR=D:\files\local\Qt\Qt5.1.1\5.1.1
+
     set Qt_DIR=C:\Qt\5.4
     set NSIS_DIR=C:\Program Files\NSIS
+
     set NSIS_DIR=C:\PROGRA~2\NSIS
 +
    set MINGW_VER=mingw491_32
  
To start building, go to the '''scripts/''' folder within the LibreCAD source folder from Windows command prompt
+
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.<br />
 +
In this case use the command '''dir /X \''' and get an output like this:
  
     cd scripts
+
     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
  
run the '''build-windows.bat'''
+
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:
  
     build-windows.bat
+
     set NSIS_DIR=C:\PROGRA~2\NSIS
  
The last step of '''build-windows.bat''' is calling NSIS to create the '''LibreCAD-Installer.exe'''.<br />
+
====custom.nsh====
If everything was OK, the installer can be found in the '''generated/''' folder within LibreCAD source folder.
+
 
+
=== Building Windows Installer by NSIS ===
+
====NSIS====
+
  
 
By default, LibreCAD uses [http://nsis.sourceforge.net/Main_Page NSIS] to generate installers in Windows.
 
By default, LibreCAD uses [http://nsis.sourceforge.net/Main_Page NSIS] to generate installers in Windows.
  
If you would like to build an installer for Windows, you will need the tool. You can use NSIS 3.0a1 version.
+
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 and Qt_Version in the '''scripts\postprocess-windows\custom-5.1.nsh''' file.
+
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'''.<br />
 +
Example for '''scripts\postprocess-windows\custom.nsh''':
  
     !define Qt_Dir "C:\Qt\Qt5.1.1"
+
     !define Qt_Dir "C:\Qt"
     !define Qt_Version "5.1.1"
+
     !define Qt_Version "5.4"
 +
    !define Mingw_Ver "mingw491_32"
  
These settings indicate Qt-5.1.1 is installed at '''C:\Qt\Qt5.1.1\5.1.1\''' and it comes with Qt-Creator at '''C:\Qt\Qt5.1.1\Tools\QtCreator\'''
+
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'''
  
====Building Windows installer====
+
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.<br />
If you build LibreCAD by command line as in the previous section, the windows installer is created automatically by the '''build-windows.bat'''.<br />
+
Then you have to add this line to '''scripts/custom-windows.bat''':
When LibreCAD Release version was build from Qt Creator, use '''build-win-setup.bat''' to create the windows installer.
+
  
     build-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.
  
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'''.
+
=== Building LibreCAD in Qt-Creator ===
  
If everything runs smoothly, you should have the installer file as,
+
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.
  
    generated\LibreCAD-installer.exe
+
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 <code>-j</code> to the make arguments can significantly improve build time.
 +
 
 +
=== 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'''.<br />
 +
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.)
 +
 
 +
Other instructions:
 +
*[[How_to_built_LibreCAD_(master_branch)_on_Windows.]]
 +
*[http://librecad.org/cms/home/from-source/windows.html LibreCad from source]
  
 
==Building LibreCAD-2.0 on OS/X==
 
==Building LibreCAD-2.0 on OS/X==
===MacPorts===
+
===LibreCAD in MacPorts===
 
Starting from version 2.0.2, LibreCAD is included [http://en.wikipedia.org/wiki/MacPorts MacPorts], which can be downloaded from http://www.macports.org/install.php
 
Starting from version 2.0.2, LibreCAD is included [http://en.wikipedia.org/wiki/MacPorts MacPorts], which can be downloaded from http://www.macports.org/install.php
  
Line 124: Line 186:
  
 
     $ sudo port selfupdate
 
     $ sudo port selfupdate
 
If you are running an OS/X version older than Mavericks(10.9), you may have to install and use gcc-4.8
 
 
    $ sudo port install gcc48
 
    $ sudo port select gcc
 
 
Accept gcc48 as the current active gcc.
 
  
 
Install the LibreCAD package
 
Install the LibreCAD package
Line 138: Line 193:
 
Following steps describe steps to build LibreCAD manually.
 
Following steps describe steps to build LibreCAD manually.
  
===Install dependecies===
+
===Alternative: Building from Downloaded Source Code===
install macports from http://www.macports.org/
+
====Install dependecies====
 +
Install QT and a new gcc, which should be version 4.7 or later (gcc-4.8 or later is recommended).
 +
 
 +
Install a version of Qt, boost and freetype, for example
 +
 
 +
    $ sudo port install gcc48 qt4-creator-mac qt4-mac boost freetype
 +
 
 +
or
 +
 
 +
    $ sudo port install gcc49 qt5-creator-mac qt5-mac boost freetype
 +
 
 +
Again, if you are running an OS/X version before Mavericks(10.9), you may have to select gcc-4.8 (or later) as the default compiler:
 +
 
 +
    $ sudo port select gcc
 +
 
 +
Accept mp-gcc48(or later) as the current active gcc.
  
After that install QT and a new gcc, which should be version 4.4 or later
+
Please note LibreCAD uses a patched version muparser, and the muparser package from MacPorts is not a required dependency any more.
  
Install a version of Qt, boost and muparser, for example
+
====Get Latest LibreCAD Source Code====
 +
To test the latest LibreCAD version, you may clone the [https://github.com/LibreCAD/LibreCAD official repository], and this cloning only needs to be done once. The latest development version of LibreCAD-2.0 is the master branch.
  
    $ sudo port install gcc46 qt4-creator-mac qt4-mac boost muparser freetype
+
Alternatively, you may download source code zipballs/tarballs from github: https://github.com/LibreCAD/LibreCAD/releases
  
===Get Latest LibreCAD Source Code===
+
<pre>
To test the latest LibreCAD version, you may clone the official repository to your local, and this cloning only needs to be done once. Alternatively, you may download source code zipballs/tarballs from github: https://github.com/LibreCAD/LibreCAD/releases
+
 
     $ sudo port install git-core
 
     $ sudo port install git-core
 
     $ mkdir -p ~/github
 
     $ mkdir -p ~/github
 
     $ cd ~/github
 
     $ cd ~/github
 
     $ git clone https://github.com/LibreCAD/LibreCAD.git
 
     $ git clone https://github.com/LibreCAD/LibreCAD.git
 +
</pre>
  
 
The last git command will clone the official LibreCAD repository to a folder ~/github/LibreCAD/
 
The last git command will clone the official LibreCAD repository to a folder ~/github/LibreCAD/
Line 158: Line 229:
 
     $ cd ~/github/LibreCAD/
 
     $ cd ~/github/LibreCAD/
 
     $ git fetch origin
 
     $ git fetch origin
 +
    $ git checkout master
 
     $ git rebase origin/master
 
     $ git rebase origin/master
  
Line 163: Line 235:
 
     $ echo "QT_CONFIG -= no-pkg-config" >> custom.pro
 
     $ echo "QT_CONFIG -= no-pkg-config" >> custom.pro
  
===Select the right compiler===
+
====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
+
LibreCAD doesn't build with the default llvm-gcc42. For example you may choose gcc48 by:
  
Run the following command to build a makefile in the LibreCAD source folder (as in our example, ~/github/LibreCAD/ )
+
    $ sudo port install gcc48
 +
    $ sudo port select --set gcc mp-gcc48
 +
====Building LibreCAD====
 +
On [http://en.wikipedia.org/wiki/OS_X_Mavericks 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 mkspec/macports
+
     $ qmake librecad.pro -r -spec macx-g++
When building on [http://en.wikipedia.org/wiki/OS_X_Mavericks Mavericks], you may use the system default clang++ compiler instead of gcc
+
  
    $ qmake librecad.pro -r
+
On OS/X version [http://en.wikipedia.org/wiki/OS_X_Mountain_Lion 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:
 
If the previous step is successful, you can build LibreCAD by issuing:
  
Line 185: Line 259:
 
===By the building script===
 
===By the building script===
  
Alternatively, you may try the building script comes with LibreCAD at scripts/build-osx.sh to build an DMG file:
+
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 ~/github/LibreCAD/
 
     $ cd scripts/
 
     $ cd scripts/
 
     $ ./build-osx.sh
 
     $ ./build-osx.sh
  
To build installers for OS/X releases from 10.6 10.9, you may run the script build-dmg.sh
+
On OS/X 10.8 or older, you may have to edit the build-osx.sh to qmake command lines like:
     $ scripts/build-dmg.sh
+
 
 +
     qmake -r -spec mkspec/macports
 +
 
 +
to use the qmake mkspec shipped within LibreCAD source code.
 +
 
 +
[[Category:Developers]]
 +
[[Category:Installation]]

Revision as of 19:10, 25 May 2016

Git and GitHub

https://github.com/LibreCAD/LibreCAD/wiki/Git-and-GitHub

Building LibreCAD 2.0 on Linux

Install dependencies

First gather the required packages:

   $ 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

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").

If you have not cloned the LibreCAD repository

If you have a local LibreCAD repository, continue to Update a local LibreCAD repository instead

If ~/develop does not exist, create this folder

   $ mkdir -p ~/develop/LibreCAD 

Clone the LibreCAD repository, please note this is needed only once

   $ cd ~/develop/
   $ git clone https://github.com/LibreCAD/LibreCAD.git

Update a local LibreCAD repository

   $ cd ~/develop/LibreCAD/
   $ git checkout master
   $ git pull -r

Build LibreCAD

   $ qmake -r
   $ make -j4

if building is successful, the generated executable is at ./unix/librecad, and you may launch LibreCAD:

   $ ./unix/librecad &

Installing Linux and building LibreCad on android devices in a Linux chroot environment

Detailed steps are here: [1]

Building LibreCAD 2.0 on Windows

Cloning the source package

To clone LibreCAD source code by command line:

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

On Windows, you may alternatively:

  • download and install msysgit
  • press the windows-key and then type git
  • select "Git GUI"
  • after the program loads select "Clone existing repository"
    • enter source location: git://github.com/LibreCAD/LibreCAD.git
    • enter target directory: where you want the project on your hard drive
  • press clone and then wait for it to download

Updating local source

  • press the windows-key and then type git
  • select "Git Bash"
  • input: cd /c/your_project_folder
  • input: git pull -r

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 only care about building with Qt Creator, then you only need to read the boost and custom.pro section. The other custom files are for when you want to create an installer.

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.

boost and custom.pro

Download boost from: boost download.

Unzip the boost files to the directory: C:\boost\ -- the extracted folder would be: C:\boost\boost_1_60_0\ .

Verify that you have the file C:\boost\boost_1_60_0\booststrap.bat. You don't have to build boost in order to build LibreCAD, because LibreCAD only uses headers.

In librecad/src edit the custom.pro (or custom.pri) file accordingly :

   BOOST_DIR = C:/boost/boost_1_60_0/
   BOOST_LIBDIR = C:/boost/boost_1_60_0/

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:

   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:

   set NSIS_DIR=C:\PROGRA~2\NSIS

custom.nsh

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

   !define Qt_Dir "C:\Qt"
   !define Qt_Version "5.4"
   !define Mingw_Ver "mingw491_32"

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

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

Other instructions:

Building LibreCAD-2.0 on OS/X

LibreCAD in MacPorts

Starting from version 2.0.2, LibreCAD is included MacPorts, which can be downloaded from http://www.macports.org/install.php

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 dependecies

Install QT and a new gcc, which should be version 4.7 or later (gcc-4.8 or later is recommended).

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

   $ sudo port install gcc48 qt4-creator-mac qt4-mac boost freetype

or

   $ sudo port install gcc49 qt5-creator-mac qt5-mac boost freetype

Again, if you are running an OS/X version before Mavericks(10.9), you may have to select gcc-4.8 (or later) as the default compiler:

   $ sudo port select gcc

Accept mp-gcc48(or later) 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

Building LibreCAD

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

   LibreCAD.app/Contents/MacOS/LibreCAD

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.