Update build instructions for the new, no-wxwidgets world
[novacoin.git] / doc / build-osx.txt
1 Copyright (c) 2010 Laszlo Hanyecz
2 Portions Copyright (c) 2011 Douglas Huff
3 Distributed under the MIT/X11 software license, see the accompanying file
4 license.txt or http://www.opensource.org/licenses/mit-license.php.  This
5 product includes software developed by the OpenSSL Project for use in the
6 OpenSSL Toolkit (http://www.openssl.org/).  This product includes cryptographic
7 software written by Eric Young (eay@cryptsoft.com) and UPnP software written by
8 Thomas Bernard.
9
10
11 Mac OS X bitcoind build instructions
12 Laszlo Hanyecz <solar@heliacal.net>
13 Douglas Huff <dhuff@jrbobdobbs.org>
14
15
16 See readme-qt.rst for instructions on building Bitcoin QT, the
17 graphical user interface.
18
19 Tested on 10.5 and 10.6 intel.  PPC is not supported because it's big-endian.
20
21 All of the commands should be executed in Terminal.app.. it's in
22 /Applications/Utilities
23
24 You need to install XCode with all the options checked so that the compiler and
25 everything is available in /usr not just /Developer I think it comes on the DVD
26 but you can get the current version from http://developer.apple.com
27
28
29 1.  Pick a directory to work inside.. something like ~/bitcoin works.  The
30 structure I use looks like this:
31
32 (~ is your home directory)
33
34 ~/bitcoin
35 ~/bitcoin/bitcoin       # Upstream source tree
36 ~/bitcoin/src           # source code (symlink to ~/bitcoin/bitcoin/src)
37 ~/bitcoin/deps          # dependencies.. like libraries and headers needed to compile
38
39 Just execute: mkdir ~/bitcoin
40 This will create the top dir for you..
41
42 WARNING: do not use the ~ notation with the configure scripts.. use the full
43 name of the directory, for example /Users/james/bitcoin/deps for a user named
44 'james'.  In my examples I am using 'macosuser' so make sure you change that.
45
46 2.  Check out the bitcoin code from github:
47
48 cd ~/bitcoin
49 git clone https://github.com/bitcoin/bitcoin.git
50 ln -s bitcoin/src src
51
52 This will make ~/bitcoin/bitcoin for you with all the files from git. This puts
53 the actual sources in ~/bitcoin/bitcoin/src and create a symlink src in
54 ~/bitcoin to this location.
55
56 3.  Get and build the dependencies
57
58
59 Boost
60 -----
61
62 Download from http://www.boost.org/users/download/
63 I'm assuming it ended up in ~/Downloads..
64
65 mkdir ~/bitcoin/deps
66 cd ~/bitcoin/deps
67 tar xvjf ~/Downloads/boost_1_42_0.tar.bz2
68 cd boost_1_42_0
69 ./bootstrap.sh
70 ./bjam architecture=combined address-model=32_64 macosx-version=10.5 macosx-version-min=10.5 link=static runtime-link=static --toolset=darwin --prefix=/Users/macosuser/bitcoin/deps install
71
72 If you're using Snow Leopard, you will need to specify 10.6 as your Mac OS X
73 version instead of 10.5.
74
75 This part takes a while.. use your judgement and fix it if something doesn't
76 build for some reason.
77
78 Change the prefix to whatever your directory is (my username in this example
79 is macosuser).  I'm also running on 10.6 so i have macosx-version=10.6  change
80 to 10.5 if you're using leopard.
81
82 This is what my output looked like at the end:
83 ...failed updating 2 targets...
84 ...skipped 144 targets...
85 ...updated 8074 targets...
86
87
88 OpenSSL
89 -------
90
91 (System or MacPorts openssl will work fine. Optional.)
92
93 Download from http://www.openssl.org/source/
94
95 We would like to build this as a 32 bit/64 bit library so we actually build it
96 2 times and join it together here..  If you downloaded with safari it already
97 uncompressed it so it will just be a tar not a tar.gz
98
99 cd ~/bitcoin/deps
100 tar xvf ~/Downloads/openssl-1.0.0.tar
101 mv openssl-1.0.0 openssl-1.0.0-i386
102 tar xvf ~/Downloads/openssl-1.0.0.tar
103 mv openssl-1.0.0 openssl-1.0.0-x86_64
104 # build i386 (32 bit intel) binary
105 cd openssl-1.0.0-i386
106 ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin-i386-cc && make
107 make install # only do this on one of the architectures, to install the headers
108 cd ..
109 # build x86_64 (64 bit intel) binary
110 cd openssl-1.0.0-x86_64
111 ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin64-x86_64-cc && make
112 cd ..
113
114 # combine the libs
115 cd ~/bitcoin/deps
116 lipo -arch i386 openssl-1.0.0-i386/libcrypto.a -arch x86_64 openssl-1.0.0-x86_64/libcrypto.a -o lib/libcrypto.a -create
117 lipo -arch i386 openssl-1.0.0-i386/libssl.a -arch x86_64 openssl-1.0.0-x86_64/libssl.a -o lib/libssl.a -create
118
119 Verify your binaries
120
121 file lib/libcrypto.a
122
123 output should look like this:
124
125 lib/libcrypto.a: Mach-O universal binary with 2 architectures
126 lib/libcrypto.a (for architecture i386):  current ar archive random library
127 lib/libcrypto.a (for architecture x86_64):  current ar archive random library
128
129
130 miniupnpc
131 ---------
132
133 (MacPorts miniupnpc package works fine. You will need to modify makefile.)
134
135 The process for miniupnpc (optional) is similar to that of OpenSSL.
136
137 Download from http://miniupnp.tuxfamily.org/files/.
138
139 cd ~/bitcoin/deps
140 tar xvf ~/Downloads/miniupnpc-1.6.tar
141 mv miniupnpc-1.6 miniupnpc-1.6-x86_64
142 tar xvf ~/Downloads/miniupnpc-1.6.tar
143 mv miniupnpc-1.6 miniupnpc-1.6-i386
144 # build x86_64 (64 bit intel) binary
145 cd miniupnpc-1.6-x86_64
146 export CFLAGS="-arch x86_64"
147 export LDFLAGS="-arch x86_64"
148 export PREFIX="/Users/macuser/bitcoin/deps"
149 make && make install
150 # build i386 (32 bit intel) binary
151 cd miniupnpc-1.6-i386
152 export CFLAGS="-arch i386"
153 export LDFLAGS="-arch i386"
154 export PREFIX="/Users/macuser/bitcoin/deps"
155 make
156
157 # combine the libs
158 cd ~/bitcoin/deps
159 lipo -arch i386 miniupnpc-1.6-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.6-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create
160
161 Verify your binaries
162
163 file lib/libminiupnpc.a
164
165 output should look like this:
166
167 lib/libminiupnpc.a: Mach-O universal binary with 2 architectures
168 lib/libminiupnpc.a (for architecture i386): current ar archive random library
169 lib/libminiupnpc.a (for architecture x86_64): current ar archive random library
170
171
172 Berkeley DB
173 -----------
174
175 (System or MacPorts version work fine.)
176
177 Download from http://freshmeat.net/projects/berkeleydb/
178
179 cd ~/bitcoin/deps
180 tar xvf ~/Downloads/db-4.8.30.tar
181 cd db-4.8.30/build_unix
182 ../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install
183
184
185 Now you should be able to build bitcoind:
186
187 cd ~/bitcoin/src
188 make -f makefile.osx bitcoind