COMPILING.txt 6.44 KB
Newer Older
1 2 3
Compiling KiCad from Source
===========================
KiCad Documentation Team
4
Last revised on 12-mars-2012 by jp Charras
5 6 7 8 9 10 11 12 13 14 15 16

Introduction
------------
This is a generic guide how to compile kicad from scratch. On windows and linux.
If you need something more distribution specific or the experimental mac-osx port
read the other documents in the Documentation/compiling folder.

Installation of Tools
---------------------
On windows:

Get msys and mingw here:
dickelbeck's avatar
dickelbeck committed
17 18 19 20 21 22
http://mingw.org/
msys sets up a development environment that allows the bash shell to run.
mingw are a set of tools that run on windows or under msys.  You will need
at least the following mingw packages: make, gcc, g++, binutils, autoconf, and
automake.

23
On linux:
24

25 26
Install "mesa".  Use your package manager to install the
development libaries.
27

28 29 30
After a fresh install you need the following packages to compile and run
KiCad from source.

31 32 33 34
* bzr     - Bazaar version control system
* CMake   - Cross-platform make
* GLUT    - The OpenGL Utility Library
* wxGTK or wxWidgets  - The wxWidgets GUI toolkit with GTK+ bindings
35

36 37 38
* Boost   - Collection of portable C++ source libraries
boost will be automagically downloaded and copied in kicad sources tree,
the first time you compile kicad.
39 40

Useful, but not required:
41
* Doxygen - Documentation system for several programming languages
42

43 44 45 46
KiCad uses the Bazaar version control system to track source code changes,
and download the boost libraries needed by Kicad.
Be sure you bzr install also includes bzrtools.
boost libraries will be downloaded the first time you build Kicad.
47 48

Compiler and basic development tools
49 50
-------------
Make sure g++, make and other tools are in your path.
dickelbeck's avatar
dickelbeck committed
51 52
If windows, then try running g++ and make from within your msys bash shell.

53 54 55
PLEASE NOTE: g++ 4.7.1 at least (possibly the 4.7.x series) is known to
miscompile pcbnew (it get zones wrong) with -O2; using -O1 is a suitable
workaround until they fix the compiler.
56

57 58
Install or Build wxWidgets
--------------------------
59 60 61 62

WARNING:
 see wxWidgets_patch_notes.txt for patches and issues in wxWidgets.

63
If on Windows, download
64
http://sourceforge.net/projects/wxwindows/files/wxAll/2.9.3/wxWidgets-2.9.3.zip/download
65
or a newer version.
66 67 68 69
Do NOT use previous versions which all have annoying issues for KiCad.
Start msys so you have a bash shell.
Note also since 2.9 versions no need to build a "debug" version of the wxWidgets library,
the release abd the debug version are same.
f3nix's avatar
f3nix committed
70

71 72
Unzip the wxWidgets zip file into the build directory.  Change directories into
there, and then:
f3nix's avatar
f3nix committed
73

74 75 76
    mkdir Release
    cd Release
    ../configure --enable-unicode --enable-monolithic=no --disable-shared --with-opengl
f3nix's avatar
f3nix committed
77 78
    make

79 80
    and under Linux, but not under Windows:
    sudo make install that install wxWidgets libs and headers in /usr/local/
81

dickelbeck's avatar
dickelbeck committed
82

83
If on linux, you can use your package manager to install the
84 85 86 87
development versions of the wxWidgets packages which include the C++ headers. An
alternative is to build static libaries from source. Verify that wx-config is in
your path by running it from a command prompt. Linux users then go to next step.

88 89
Install CMake
-------------
charras's avatar
charras committed
90
If windows, download the installation binary for windows from cmake.org.
dickelbeck's avatar
dickelbeck committed
91 92 93 94
Install that and choose to add cmake to your path during installation.  You
will have to restart and command shells for the new path to take effect.
Verify that cmake is in your path by trying to run it from a command prompt.

95

96
If linux, use your package manager to install cmake. You should get cmake 2.6.4
dickelbeck's avatar
dickelbeck committed
97
or later. If only an older one is available in your package repository, build
98
cmake from source. Verify that cmake is in your path by trying to run it from a
dickelbeck's avatar
dickelbeck committed
99 100
command prompt.

101

102 103
Obtain Sources
--------------
104
You can use the Launchpad repository or a tar file for this.  See the wiki.
105 106
To download files from  Launchpad repository, you should install bazaar (bzr) that is a
version control system like subversion, mercurial, git...
107

108
Launchpad repository handle 2 branches for KiCda sources:
109 110
- a testing branch (used by developers)
- a stable branch (a copy of the testing branch, when this testing branch is near a stable state))
dickelbeck's avatar
dickelbeck committed
111

112 113 114 115 116 117 118 119 120 121 122
Testing branch:
bzr branch lp:kicad kicad_testing

Stable branch:
bzr branch lp:kicad/stable kicad_stable

Components and Footprints libraries
bzr branch lp:~kicad-lib-committers/kicad/library kicad_libraries

Documentation and translations:
bzr branch lp:~kicad-developers/kicad/doc kicad_doc
123

124 125
Create Makefiles with CMake
---------------------------
charras's avatar
charras committed
126
If windows, go into your msys shell.  Linux and windows users both then make
dickelbeck's avatar
dickelbeck committed
127 128
two "out of source" build directories:
    cd <kicadSource>
f3nix's avatar
f3nix committed
129
    mkdir -p build/release
130
    mkdir build/debug   (if you want a debug version of KiCad)
f3nix's avatar
f3nix committed
131
    cd build/release
dickelbeck's avatar
dickelbeck committed
132 133 134

On either cmake command line shown below, you can optionally include
    -DCMAKE_INSTALL_PREFIX=<finallInstallDir>
135

dickelbeck's avatar
dickelbeck committed
136
If windows, run the following command:
137
    cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release  -DKICAD_TESTING_VERSION=ON -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
dickelbeck's avatar
dickelbeck committed
138 139

If linux, run instead the following command:
140
    cmake -DCMAKE_BUILD_TYPE=Release ../../
dickelbeck's avatar
dickelbeck committed
141 142 143 144 145 146

Take a look at CMakeCache.txt, and in particular CMAKE_INSTALL_PREFIX, which
gives the final install directory. If not what you want, edit it with a text
editor and re-run the same cmake command again, but with no
-DCMAKE_INSTALL_PREFIX given on the command line.

147 148
Compiling with Make
------------------~
charras's avatar
charras committed
149
You compile Kicad here.  You will only need to do step 8) again when one of the
dickelbeck's avatar
dickelbeck committed
150 151
CMakeLists.txt files change.  If windows, you must be in your msys shell.
On either platform then:
152

f3nix's avatar
f3nix committed
153
    cd <kicadSource>/build/release
dickelbeck's avatar
dickelbeck committed
154 155 156 157 158
    make
    [sudo] make install

You are now done unless you want to make a Debug build.

159

160 161
Compiling a Debug version
-------------------------
f3nix's avatar
f3nix committed
162
    cd <kicadSource>/build/debug
dickelbeck's avatar
dickelbeck committed
163 164

On either cmake command line shown below, you can optionally include
165 166 167
-DCMAKE_INSTALL_PREFIX=<finallInstallDir> before the final ../../ argument.
Although normally you do not install the Debug binaries, you can debug them
where they were built.
dickelbeck's avatar
dickelbeck committed
168 169

If windows, run the following command:
170 171
    cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug -DKICAD_TESTING_VERSION=ON -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
where <wxInstallDir> is <wxWidgets path>/Release
dickelbeck's avatar
dickelbeck committed
172 173

If linux, run instead the following command:
174
    cmake -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_USE_DEBUG=ON ../../
dickelbeck's avatar
dickelbeck committed
175 176 177

Make the Debug binaries:
    make
178 179

Note: that it is easy to build only a specific binary such as pcbnew alone:
dickelbeck's avatar
dickelbeck committed
180
    make pcbnew
181 182 183


See ./cmake_config.txt for customizing the KiCad build setting.