COMPILING.txt 7.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Compiling KiCad from Source
===========================
KiCad Documentation Team
Last revised on 31-Jan-2010 by Jerry Jacobs

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
Tools in PATH
-------------
Make sure g++, make and other tools are in your path.
dickelbeck's avatar
dickelbeck committed
31 32
If windows, then try running g++ and make from within your msys bash shell.

33

34 35
Install or Build wxWidgets
--------------------------
dickelbeck's avatar
dickelbeck committed
36
If on windows, download
37 38
http://sourceforge.net/projects/wxwindows/files/wxAll/2.8.10/wxWidgets-2.8.10.zip/download
or a newer version.
dickelbeck's avatar
dickelbeck committed
39
Start msys so you have a bash shell.  Decide where your wxWidgets build directory
charras's avatar
charras committed
40 41
will be.  It must be where you can access it from within the msys environment,
such as home/<user>.   Edit your msys/1.0/etc/fstab file if needed to provide
f3nix's avatar
f3nix committed
42 43 44
access to this build directory from msys.  (Note that if you want you can build
a "debug" version of the wxWidgets library at this point, instead of the release
version, or in addition to the the release version.)
45 46
Unzip the wmMWS zip file into the build directory.  Change directories into
there, and then:
f3nix's avatar
f3nix committed
47 48 49 50

    mkdir build-release
    mkdir build-debug

51 52
.Release
----
f3nix's avatar
f3nix committed
53 54
    cd build-release
    ../configure --enable-unicode --enable-monolithic --disable-shared --with-msw --with-opengl
dickelbeck's avatar
dickelbeck committed
55 56
    make
    make install
57
----
f3nix's avatar
f3nix committed
58

59 60
.Debug
----
f3nix's avatar
f3nix committed
61
    cd build-debug
62
    ../configure --enable-unicode --enable-monolithic --enable-debug --enable-debug_gdb --disable-shared --with-msw --with-opengl
f3nix's avatar
f3nix committed
63 64
    make
    make install
65
----
f3nix's avatar
f3nix committed
66

67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
The default install path is /usr/local.  Generally speaking MinGW likes header
files in /mingw/include and library link files in /mingw/lib.  You can install
path by setting --prefix=/mingw to configure above to change where "make install"
puts everything.  We will refer to the --prefix setting as <wxInstallDir> below.

If you are planning to enable the USE_WX_GRAPHICS_CONTEXT option (see options
section below) on Windows using MinGW/MSYS you must build wxWidgets with the
--enable-graphics_ctx switch added to the build configurations above.
Unfortunately it is not quite that simple because MinGW does not define the
Gdi+ header and link library files.  First you must download the required Gdi+
development files from

<http://www.miscdebris.net/blog/2009/09/17/adding-gdi-headers-to-mingw-to-compile-wxwidgets-with-wxgraphicscontext-support/>

and unzip them where MinGW is installed.
dickelbeck's avatar
dickelbeck committed
82 83

Verify that wx-config is in your path.  Modify your PATH environment variable
charras's avatar
charras committed
84
if need be so you can run wx-config from a command prompt.  You may have to
dickelbeck's avatar
dickelbeck committed
85 86
restart your msys shell, depending on how you modify your PATH.

87 88 89 90 91
If on linux, use your package manager to install shared object libraries and the
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.

92

93 94
Install or Build zlib
---------------------
95 96 97
If on windows, download http://www.zlib.net/zlib123.zip or a newer version.
Start msys so you have a bash shell. Decide where your zlib build directory
will be. It must be where you can access it from within the msys environment,
charras's avatar
charras committed
98 99
such as home/<user>. Edit your msys/1.0/etc/fstab file if needed to provide
access to this build directory from msys. Unzip the zlib123.zip file into this
100
build directory. Change directories into there, and then:
101

f3nix's avatar
f3nix committed
102
    ./configure
103 104 105 106 107 108 109
    make
    make install


If linux, use your package manager to install zlib pre-built binaries.

Note (JP Charras):
110 111 112 113 114
Under Linux, zlib is usually installed.
If it is not found by the wxWidget installation, wxWidgets creates an alternate zlib library.
Under Windows, if zlib is not installed, my cmake build will try to use the
wxWidgets zlib build.  So, under windows kicad build should work without
zlib install.
115

116
If you are using the wxWidget zlib, make sure that the wxWidgets/src/zlib directory is copied
117
to ${wxWidgets_ROOT_DIR}/src/zlib
118

119 120
Install CMake
-------------
charras's avatar
charras committed
121
If windows, download the installation binary for windows from cmake.org.
dickelbeck's avatar
dickelbeck committed
122 123 124 125
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.

126

127
If linux, use your package manager to install cmake. You should get cmake 2.6.1
dickelbeck's avatar
dickelbeck committed
128
or later. If only an older one is available in your package repository, build
129
2.6.1 from source. Verify that cmake is in your path by trying to run it from a
dickelbeck's avatar
dickelbeck committed
130 131
command prompt.

132

133 134
Obtain Sources
--------------
charras's avatar
charras committed
135
You can use the subversion repository or a tar file for this.  See the wiki.
dickelbeck's avatar
dickelbeck committed
136

137

138 139
Create Makefiles with CMake
---------------------------
charras's avatar
charras committed
140
If windows, go into your msys shell.  Linux and windows users both then make
dickelbeck's avatar
dickelbeck committed
141 142
two "out of source" build directories:
    cd <kicadSource>
f3nix's avatar
f3nix committed
143 144 145
    mkdir -p build/release
    mkdir build/debug
    cd build/release
dickelbeck's avatar
dickelbeck committed
146 147 148

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

dickelbeck's avatar
dickelbeck committed
150
If windows, run the following command:
151
    cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
dickelbeck's avatar
dickelbeck committed
152 153

If linux, run instead the following command:
154
    cmake -DCMAKE_BUILD_TYPE=Release ../../
dickelbeck's avatar
dickelbeck committed
155 156 157 158 159 160

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.

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

f3nix's avatar
f3nix committed
167
    cd <kicadSource>/build/release
dickelbeck's avatar
dickelbeck committed
168 169 170 171 172
    make
    [sudo] make install

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

173

174 175
Compiling a Debug version
-------------------------
f3nix's avatar
f3nix committed
176
    cd <kicadSource>/build/debug
dickelbeck's avatar
dickelbeck committed
177 178

On either cmake command line shown below, you can optionally include
179 180 181
-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
182 183

If windows, run the following command:
184
    cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_USE_DEBUG=ON -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
dickelbeck's avatar
dickelbeck committed
185 186

If linux, run instead the following command:
187
    cmake -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_USE_DEBUG=ON ../../
dickelbeck's avatar
dickelbeck committed
188 189 190

Make the Debug binaries:
    make
191

192

193 194
Fine-tune Build Process
-----------------------
195 196 197 198 199 200 201 202 203
These should be set from command line:

 CMAKE_BUILD_TYPE Release/Debug (REQUIRED)
   Choose build type: Release/Debug.

 wxWidgets_USE_DEBUG ON/OFF (REQUIRED)
   Should be set to ON only when CMAKE_BUILD_TYPE=Debug.

 wxWidgets_USE_STATIC ON/OFF (OPTIONAL)
charras's avatar
charras committed
204

205 206 207 208 209
 CMAKE_VERBOSE_MAKEFILE ON/OFF (OPTIONAL)
   Turns ON/OFF verbose build messages.
   You can also pass VERBOSE=1 to make for the same effect.

 CMAKE_INSTALL_PREFIX (OPTIONAL)
charras's avatar
charras committed
210

211
 KICAD_MINIZIP ON/OFF
charras's avatar
charras committed
212

213 214 215 216 217 218 219 220 221
 USE_WX_ZOOM ON/OFF (OPTIONAL)
   Experimental coordinate translation code using wxDC instead of custom
   Kicad version.

 USE_WX_GRAPHICS_CONTEXT ON/OFF (OPTIONAL)
   Experimental advanced drawing library code using wxGraphicsContext.  It
   requires wxWidgets to be built with the --enable-graphics_ctx switch.
   See building wxWidgets above.

222
Note: that it is easy to build only a specific binary such as pcbnew alone:
dickelbeck's avatar
dickelbeck committed
223
    make pcbnew