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
11 Mac OS X build instructions
12 Laszlo Hanyecz <solar@heliacal.net>
13 Douglas Huff <dhuff@jrbobdobbs.org>
16 Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian.
18 All of the commands should be executed in Terminal.app.. it's in
19 /Applications/Utilities
21 You need to install XCode with all the options checked so that the compiler and
22 everything is available in /usr not just /Developer I think it comes on the DVD
23 but you can get the current version from http://developer.apple.com
26 1. Pick a directory to work inside.. something like ~/bitcoin works. The
27 structure I use looks like this:
29 (~ is your home directory)
32 ~/bitcoin/bitcoin # Upstream source tree
33 ~/bitcoin/src # source code (symlink to ~/bitcoin/bitcoin/src)
34 ~/bitcoin/deps # dependencies.. like libraries and headers needed to compile
35 ~/bitcoin/Bitcoin.app # the application bundle where you can run the app
37 Just execute: mkdir ~/bitcoin
38 This will create the top dir for you..
40 WARNING: do not use the ~ notation with the configure scripts.. use the full
41 name of the directory, for example /Users/james/bitcoin/deps for a user named
42 'james'. In my examples I am using 'macosuser' so make sure you change that.
44 2. Check out the bitcoin code from github:
47 git clone https://github.com/bitcoin/bitcoin.git
50 This will make ~/bitcoin/bitcoin for you with all the files from git. This puts
51 the actual sources in ~/bitcoin/bitcoin/src and create a symlink src in
52 ~/bitcoin to this location.
54 3. Get and build the dependencies
60 Download from http://www.boost.org/users/download/
61 I'm assuming it ended up in ~/Downloads..
65 tar xvjf ~/Downloads/boost_1_42_0.tar.bz2
68 ./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
70 If you're using Snow Leopard, you will need to specify 10.6 as your Mac OS X
71 version instead of 10.5.
73 This part takes a while.. use your judgement and fix it if something doesn't
74 build for some reason.
76 Change the prefix to whatever your directory is (my username in this example
77 is macosuser). I'm also running on 10.6 so i have macosx-version=10.6 change
78 to 10.5 if you're using leopard.
80 This is what my output looked like at the end:
81 ...failed updating 2 targets...
82 ...skipped 144 targets...
83 ...updated 8074 targets...
89 (System or MacPorts openssl will work fine. Optional.)
91 Download from http://www.openssl.org/source/
93 We would like to build this as a 32 bit/64 bit library so we actually build it
94 2 times and join it together here.. If you downloaded with safari it already
95 uncompressed it so it will just be a tar not a tar.gz
98 tar xvf ~/Downloads/openssl-1.0.0.tar
99 mv openssl-1.0.0 openssl-1.0.0-i386
100 tar xvf ~/Downloads/openssl-1.0.0.tar
101 mv openssl-1.0.0 openssl-1.0.0-x86_64
102 # build i386 (32 bit intel) binary
103 cd openssl-1.0.0-i386
104 ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin-i386-cc && make
105 make install # only do this on one of the architectures, to install the headers
107 # build x86_64 (64 bit intel) binary
108 cd openssl-1.0.0-x86_64
109 ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin64-x86_64-cc && make
114 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
115 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
121 output should look like this:
123 lib/libcrypto.a: Mach-O universal binary with 2 architectures
124 lib/libcrypto.a (for architecture i386): current ar archive random library
125 lib/libcrypto.a (for architecture x86_64): current ar archive random library
131 (MacPorts miniupnpc package works fine. You will need to modify makefile.)
133 The process for miniupnpc (optional) is similar to that of OpenSSL.
135 Download from http://miniupnp.tuxfamily.org/files/.
138 tar xvf ~/Downloads/miniupnpc-1.6.tar
139 mv miniupnpc-1.6 miniupnpc-1.6-x86_64
140 tar xvf ~/Downloads/miniupnpc-1.6.tar
141 mv miniupnpc-1.6 miniupnpc-1.6-i386
142 # build x86_64 (64 bit intel) binary
143 cd miniupnpc-1.6-x86_64
144 export CFLAGS="-arch x86_64"
145 export LDFLAGS="-arch x86_64"
146 export PREFIX="/Users/macuser/bitcoin/deps"
148 # build i386 (32 bit intel) binary
149 cd miniupnpc-1.6-i386
150 export CFLAGS="-arch i386"
151 export LDFLAGS="-arch i386"
152 export PREFIX="/Users/macuser/bitcoin/deps"
157 lipo -arch i386 miniupnpc-1.6-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.6-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create
161 file lib/libminiupnpc.a
163 output should look like this:
165 lib/libminiupnpc.a: Mach-O universal binary with 2 architectures
166 lib/libminiupnpc.a (for architecture i386): current ar archive random library
167 lib/libminiupnpc.a (for architecture x86_64): current ar archive random library
173 (System or MacPorts version work fine.)
175 Download from http://freshmeat.net/projects/berkeleydb/
178 tar xvf ~/Downloads/db-4.8.30.tar
179 cd db-4.8.30/build_unix
180 ../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install
186 (The wxWidgets-devel MacPorts package will work but will throw annoying assertion dialogs.)
188 This is the big one..
190 Check it out from svn
193 svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk
195 This will make a wxWidgets-trunk directory in deps.
197 Use this script snippet, change your prefix to whatever your dir is:
199 PREFIX=~/bitcoin/deps
200 SRCDIR="$PREFIX/wxWidgets-trunk"
201 BUILDDIR="$SRCDIR/macbuild"
204 #svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk &&
207 [ -f include/wx/hashmap.h.orig ] || cp include/wx/hashmap.h include/wx/hashmap.h.orig &&
208 sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashmap.h.orig > include/wx/hashmap.h &&
210 [ -f include/wx/hashset.h.orig ] || cp include/wx/hashset.h include/wx/hashset.h.orig &&
211 sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashset.h.orig > include/wx/hashset.h &&
215 rm -vrf "$BUILDDIR" &&
219 ../configure --prefix="$PREFIX" \
222 --disable-debug_flag \
223 --with-macosx-version-min=10.5 \
226 --enable-universal_binary \
227 --with-libjpeg=builtin \
228 --with-libpng=builtin \
229 --with-regex=builtin \
230 --with-libtiff=builtin \
231 --with-zlib=builtin \
232 --with-expat=builtin \
233 --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk &&
236 find . -name Makefile |
239 sed 's/-arch i386/-arch i386 -arch x86_64/g' < "$i" > "$i".new &&
251 Now you should be able to build bitcoin
254 make -f makefile.osx bitcoin
256 Before you can run it, you need to create an application bundle for Mac OS.
258 A bundle is provided in contrib/Bitcoin.app.
260 Copy the bitcoin binary in to it like this:
261 cp -pR ~/bitcoin/bitcoin/contrib/Bitcoin.app ~/bitcoin/
262 cp ~/bitcoin/src/bitcoin ~/bitcoin/Bitcoin.app/Contents/MacOS/
264 To run it you can just click the Bitcoin.app in Finder, or just do:
265 open ~/bitcoin/Bitcoin.app
267 If you want to run it with arguments you can just run it without backgrounding
268 by specifying the full name in terminal:
270 ~/bitcoin/Bitcoin.app/Contents/MacOS/bitcoin -addnode=192.75.207.66
272 You can also run it with arguments in the background with output going to the
273 normal places for apps (Console) like this:
275 open ~/bitcoin/Bitcoin.app --args -connect=192.75.207.66
277 It is advisable to relocate Bitcoin.app to /Applications or $HOME/Applications.