1 Copyright (c) 2010 Laszlo Hanyecz
2 Distributed under the MIT/X11 software license, see the accompanying
3 file license.txt or http://www.opensource.org/licenses/mit-license.php.
4 This product includes software developed by the OpenSSL Project for use in
5 the OpenSSL Toolkit (http://www.openssl.org/). This product includes
6 cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP
7 software written by Thomas Bernard.
10 Mac OS X build instructions
11 Laszlo Hanyecz (solar@heliacal.net)
14 Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian.
16 All of the commands should be executed in Terminal.app.. it's in
17 /Applications/Utilities
19 You need to install XCode with all the options checked so that the compiler
20 and everything is available in /usr not just /Developer
21 I think it comes on the DVD but you can get the current version from
22 http://developer.apple.com
25 1. Pick a directory to work inside.. something like ~/bitcoin works. The
26 structure I use looks like this:
27 (~ is your home directory)
30 ~/bitcoin/trunk # source code
31 ~/bitcoin/deps # dependencies.. like libraries and headers needed to compile
32 ~/bitcoin/Bitcoin.app # the application bundle where you can run the app
34 Just execute: mkdir ~/bitcoin
35 This will create the top dir for you..
37 WARNING: do not use the ~ notation with the configure scripts.. use the full
38 name of the directory, for example /Users/james/bitcoin/deps for a user named
39 'james'. In my examples I am using 'macosuser' so make sure you change that.
41 2. Check out the trunk version of the bitcoin code from subversion:
44 svn checkout https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk
46 This will make ~/bitcoin/trunk for you with all the files from subversion.
48 3. Get and build the dependencies
54 Download from http://www.boost.org/users/download/
55 I'm assuming it ended up in ~/Downloads..
59 tar xvjf ~/Downloads/boost_1_42_0.tar.bz2
62 ./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
64 If you're using Snow Leopard, you will need to specify 10.6 as your Mac OS X
65 version instead of 10.5.
67 This part takes a while.. use your judgement and fix it if something doesn't
68 build for some reason.
70 Change the prefix to whatever your directory is (my username in this example
71 is macosuser). I'm also running on 10.6 so i have macosx-version=10.6 change
72 to 10.5 if you're using leopard.
74 This is what my output looked like at the end:
75 ...failed updating 2 targets...
76 ...skipped 144 targets...
77 ...updated 8074 targets...
83 Download from http://www.openssl.org/source/
85 We would like to build this as a 32 bit/64 bit library so we actually build it
86 2 times and join it together here.. If you downloaded with safari it already
87 uncompressed it so it will just be a tar not a tar.gz
90 tar xvf ~/Downloads/openssl-1.0.0.tar
91 mv openssl-1.0.0 openssl-1.0.0-i386
92 tar xvf ~/Downloads/openssl-1.0.0.tar
93 mv openssl-1.0.0 openssl-1.0.0-x86_64
94 # build i386 (32 bit intel) binary
96 ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin-i386-cc && make
97 make install # only do this on one of the architectures, to install the headers
99 # build x86_64 (64 bit intel) binary
100 cd openssl-1.0.0-x86_64
101 ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin64-x86_64-cc && make
106 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
107 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
113 output should look like this:
115 lib/libcrypto.a: Mach-O universal binary with 2 architectures
116 lib/libcrypto.a (for architecture i386): current ar archive random library
117 lib/libcrypto.a (for architecture x86_64): current ar archive random library
123 The process for miniupnpc (optional) is similar to that of OpenSSL.
125 Download from http://miniupnp.tuxfamily.org/files/.
128 tar xvf ~/Downloads/miniupnpc-1.5.tar
129 mv miniupnpc-1.5 miniupnpc-1.5-x86_64
130 tar xvf ~/Downloads/miniupnpc-1.5.tar
131 mv miniupnpc-1.5 miniupnpc-1.5-i386
132 # build x86_64 (64 bit intel) binary
133 cd miniupnpc-1.5-x86_64
134 export CFLAGS="-arch x86_64"
135 export LDFLAGS="-arch x86_64"
136 export PREFIX="/Users/macuser/bitcoin/deps"
138 # build i386 (32 bit intel) binary
139 cd miniupnpc-1.5-i386
140 export CFLAGS="-arch i386"
141 export LDFLAGS="-arch i386"
142 export PREFIX="/Users/macuser/bitcoin/deps"
147 lipo -arch i386 miniupnpc-1.5-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.5-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create
151 file lib/libminiupnpc.a
153 output should look like this:
155 lib/libminiupnpc.a: Mach-O universal binary with 2 architectures
156 lib/libminiupnpc.a (for architecture i386): current ar archive random library
157 lib/libminiupnpc.a (for architecture x86_64): current ar archive random library
163 Download from http://freshmeat.net/projects/berkeleydb/
166 tar xvf ~/Downloads/db-4.8.26.tar
167 cd db-4.8.26/build_unix
168 ../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install
174 This is the big one..
176 Check it out from svn
179 svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk
181 This will make a wxWidgets-trunk directory in deps.
183 Use this script snippet, change your prefix to whatever your dir is:
185 PREFIX=~/bitcoin/deps
186 SRCDIR="$PREFIX/wxWidgets-trunk"
187 BUILDDIR="$SRCDIR/macbuild"
190 #svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk &&
193 [ -f include/wx/hashmap.h.orig ] || cp include/wx/hashmap.h include/wx/hashmap.h.orig &&
194 sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashmap.h.orig > include/wx/hashmap.h &&
196 [ -f include/wx/hashset.h.orig ] || cp include/wx/hashset.h include/wx/hashset.h.orig &&
197 sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashset.h.orig > include/wx/hashset.h &&
201 rm -vrf "$BUILDDIR" &&
205 ../configure --prefix="$PREFIX" \
208 --disable-debug_flag \
209 --with-macosx-version-min=10.5 \
212 --enable-universal_binary \
213 --with-libjpeg=builtin \
214 --with-libpng=builtin \
215 --with-regex=builtin \
216 --with-libtiff=builtin \
217 --with-zlib=builtin \
218 --with-expat=builtin \
219 --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk &&
222 find . -name Makefile |
225 sed 's/-arch i386/-arch i386 -arch x86_64/g' < "$i" > "$i".new &&
237 Now you should be able to build bitcoin
240 make -f makefile.osx bitcoin
242 Before you can run it, you need to create an application bundle for Mac OS.
243 Create the directories in terminal using mkdir and copy the files into place.
244 They are available at http://heliacal.net/~solar/bitcoin/mac-build/
245 You need the Info.plist and the .ins file. The Contents/MacOS/bitcoin file is
246 the output of the build.
247 Your directory structure should look like this:
251 Bitcoin.app/Contents/Info.plist
252 Bitcoin.app/Contents/MacOS
253 Bitcoin.app/Contents/MacOS/bitcoin
254 Bitcoin.app/Contents/Resources
255 Bitcoin.app/Contents/Resources/BitcoinAppIcon.icns
257 To run it you can just click the Bitcoin.app in Finder, or just do open
258 ~/bitcoin/Bitcoin.app
259 If you want to run it with arguments you can just run it without backgrounding
260 by specifying the full name in terminal:
261 ~/bitcoin/Bitcoin.app/Contents/MacOS/bitcoin -addnode=192.75.207.66