Difference between revisions of "Build from source"

From LibreCAD wiki
Jump to: navigation, search
(MacPorts)
(Building LibreCAD-2.0 on OS/X: updated OSX building steps)
Line 116: Line 116:
  
 
==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 131: Line 131:
 
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 is recommended).
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
 
Install a version of Qt, boost and muparser, for example
  
     $ sudo port install gcc48 qt4-creator-mac qt4-mac boost muparser freetype
+
     $ 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:
 
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:
Line 146: Line 145:
 
Accept gcc48 as the current active gcc.
 
Accept gcc48 as the current active gcc.
  
===Get Latest LibreCAD Source Code===
+
Please note LibreCAD uses a patched version muparser, and the muparser package from MacPorts is not a required dependency any more.
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
+
 
 +
====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.
 +
 
 +
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
Line 157: Line 161:
 
     $ cd ~/github/LibreCAD/
 
     $ cd ~/github/LibreCAD/
 
     $ git fetch origin
 
     $ git fetch origin
 +
    $ git checkout master
 
     $ git rebase origin/master
 
     $ git rebase origin/master
  
Line 162: Line 167:
 
     $ 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:
 
LibreCAD doesn't build with the default llvm-gcc42. For example you may choose gcc46 by:
  
 
     $ sudo port select --set gcc mp-gcc46
 
     $ sudo port select --set gcc mp-gcc46
  
Run the following command to build a makefile in the LibreCAD source folder (as in our example, ~/github/LibreCAD/ )
+
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
 
     $ qmake librecad.pro -r -spec mkspec/macports
When building on [http://en.wikipedia.org/wiki/OS_X_Mavericks Mavericks], you may use the system default clang++ compiler instead of gcc
+
 
 +
When building on [http://en.wikipedia.org/wiki/OS_X_Mavericks Mavericks] or newer, you may use the system default clang++ compiler instead of gcc
  
 
     $ qmake librecad.pro -r -spec macx-clang
 
     $ qmake librecad.pro -r -spec macx-clang
 
It's recommended to build muparser from patched source included in LibreCAD (version 2.0.3 and later)
 
 
    $ qmake librecad.pro -r -spec macx-clang "build_muparser = true"
 
 
 
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 192: Line 193:
 
     $ 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
 
    $ scripts/build-dmg.sh
 

Revision as of 14:59, 12 October 2014

Building LibreCAD 2.0 on Linux

Detailed steps can be found at Build in Linux

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 [1].

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.

Qt

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

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.

boost

Introduction for boost can be found here boost introduction.

Download boost 1.53 from: boost download. Do not try version 1.54 or 1.55 (there are compilation errors on 11 Nov 2013).

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/

muParser

muParser is at muParser.

Download muParser source from: muParser Download

unzip the muParser source files to C:\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.1.1\Tools\MinGW48_32\bin;%PATH%
   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.

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

   MUPARSER_DIR = C:/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. Default Qt_Dir and NSIS_DIR are set in file scripts/set-windows-env.bat:

   set Qt_DIR=C:\Qt\Qt5.1.1\5.1.1
   set NSIS_DIR=C:\Program Files (x86)\NSIS
   set MINGW_VER=mingw48_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).
Example for scripts/custom-windows.bat:

   set Qt_DIR=D:\files\local\Qt\Qt5.1.1\5.1.1
   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

   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

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 NSIS 3.0a1 version.

You need to setup your Qt_Dir and Qt_Version in the scripts\postprocess-windows\custom-5.1.nsh file.

   !define Qt_Dir "C:\Qt\Qt5.1.1"
   !define Qt_Version "5.1.1"

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\

Building Windows installer

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.

   build-windows.bat


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,

   generated\LibreCAD-installer.exe

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 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 gcc46 by:

   $ sudo port select --set gcc mp-gcc46

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

When building on Mavericks or newer, you may use the system default clang++ compiler instead of gcc

   $ qmake librecad.pro -r -spec macx-clang

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:

   $ cd ~/github/LibreCAD/
   $ cd scripts/
   $ ./build-osx.sh