It's a c++: use string.clear()
[novacoin.git] / doc / build-osx.txt
index 7927983..0531156 100644 (file)
-Copyright (c) 2010 Laszlo Hanyecz
-Distributed under the MIT/X11 software license, see the accompanying
-file license.txt or http://www.opensource.org/licenses/mit-license.php.
-This product includes software developed by the OpenSSL Project for use in
-the OpenSSL Toolkit (http://www.openssl.org/).  This product includes
-cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP
-software written by Thomas Bernard.
+Mac OS X Build Instructions and Notes
+====================================
+This guide will show you how to build novacoind(headless client) for OSX.
 
-
-Mac OS X build instructions
-Laszlo Hanyecz (solar@heliacal.net)
-
-
-Tested on 10.5 and 10.6 intel.  PPC is not supported because it's big-endian.
-
-All of the commands should be executed in Terminal.app.. it's in
-/Applications/Utilities
-
-You need to install XCode with all the options checked so that the compiler
-and everything is available in /usr not just /Developer
-I think it comes on the DVD but you can get the current version from
-http://developer.apple.com
-
-
-1.  Pick a directory to work inside.. something like ~/bitcoin works.  The
-structure I use looks like this:
-(~ is your home directory)
-
-~/bitcoin
-~/bitcoin/trunk         # source code
-~/bitcoin/deps          # dependencies.. like libraries and headers needed to compile
-~/bitcoin/Bitcoin.app   # the application bundle where you can run the app
-
-Just execute: mkdir ~/bitcoin
-This will create the top dir for you..
-
-WARNING: do not use the ~ notation with the configure scripts.. use the full
-name of the directory, for example /Users/james/bitcoin/deps for a user named
-'james'.  In my examples I am using 'macosuser' so make sure you change that.
-
-2.  Check out the trunk version of the bitcoin code from subversion:
-
-cd ~/bitcoin
-svn checkout https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk
-
-This will make ~/bitcoin/trunk for you with all the files from subversion. 
-
-3.  Get and build the dependencies
-
-
-Boost
+Notes
 -----
 
-Download from http://www.boost.org/users/download/
-I'm assuming it ended up in ~/Downloads..
-
-mkdir ~/bitcoin/deps
-cd ~/bitcoin/deps
-tar xvjf ~/Downloads/boost_1_42_0.tar.bz2
-cd boost_1_42_0
-./bootstrap.sh
-./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
-
-If you're using Snow Leopard, you will need to specify 10.6 as your Mac OS X
-version instead of 10.5.
-
-This part takes a while.. use your judgement and fix it if something doesn't
-build for some reason.
-
-Change the prefix to whatever your directory is (my username in this example
-is macosuser).  I'm also running on 10.6 so i have macosx-version=10.6  change
-to 10.5 if you're using leopard.
+* Tested on OS X 10.7 through 10.10 on 64-bit Intel processors only.
 
-This is what my output looked like at the end:
-...failed updating 2 targets...
-...skipped 144 targets...
-...updated 8074 targets...
+* All of the commands should be executed in a Terminal application. The
+built-in one is located in `/Applications/Utilities`.
 
+Preparation
+-----------
 
-OpenSSL
--------
-
-Download from http://www.openssl.org/source/
-
-We would like to build this as a 32 bit/64 bit library so we actually build it
-2 times and join it together here..  If you downloaded with safari it already
-uncompressed it so it will just be a tar not a tar.gz
-
-cd ~/bitcoin/deps
-tar xvf ~/Downloads/openssl-1.0.0.tar
-mv openssl-1.0.0 openssl-1.0.0-i386
-tar xvf ~/Downloads/openssl-1.0.0.tar
-mv openssl-1.0.0 openssl-1.0.0-x86_64
-# build i386 (32 bit intel) binary
-cd openssl-1.0.0-i386
-./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin-i386-cc && make
-make install # only do this on one of the architectures, to install the headers
-cd ..
-# build x86_64 (64 bit intel) binary
-cd openssl-1.0.0-x86_64
-./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin64-x86_64-cc && make
-cd ..
-
-# combine the libs
-cd ~/bitcoin/deps
-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
-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
-
-Verify your binaries
-
-file lib/libcrypto.a
-
-output should look like this:
-
-lib/libcrypto.a: Mach-O universal binary with 2 architectures
-lib/libcrypto.a (for architecture i386):       current ar archive random library
-lib/libcrypto.a (for architecture x86_64):     current ar archive random library
-
-
-miniupnpc
----------
-
-The process for miniupnpc (optional) is similar to that of OpenSSL.
-
-Download from http://miniupnp.tuxfamily.org/files/.
-
-cd ~/bitcoin/deps
-tar xvf ~/Downloads/miniupnpc-1.5.tar
-mv miniupnpc-1.5 miniupnpc-1.5-x86_64
-tar xvf ~/Downloads/miniupnpc-1.5.tar
-mv miniupnpc-1.5 miniupnpc-1.5-i386
-# build x86_64 (64 bit intel) binary
-cd miniupnpc-1.5-x86_64
-export CFLAGS="-arch x86_64"
-export LDFLAGS="-arch x86_64"
-export PREFIX="/Users/macuser/bitcoin/deps"
-make && make install
-# build i386 (32 bit intel) binary
-cd miniupnpc-1.5-i386
-export CFLAGS="-arch i386"
-export LDFLAGS="-arch i386"
-export PREFIX="/Users/macuser/bitcoin/deps"
-make
-
-# combine the libs
-cd ~/bitcoin/deps
-lipo -arch i386 miniupnpc-1.5-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.5-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create
+You need to install XCode with all the options checked so that the compiler
+and everything is available in /usr not just /Developer. XCode should be
+available on your OS X installation media, but if not, you can get the
+current version from https://developer.apple.com/xcode/. If you install
+Xcode 4.3 or later, you'll need to install its command line tools. This can
+be done in `Xcode > Preferences > Downloads > Components` and generally must
+be re-done or updated every time Xcode is updated.
 
-Verify your binaries
+There's also an assumption that you already have `git` installed. If
+not, it's the path of least resistance to install [Github for Mac](https://mac.github.com/)
+(OS X 10.7+) or
+[Git for OS X](https://code.google.com/p/git-osx-installer/). It is also
+available via Homebrew.
 
-file lib/libminiupnpc.a
+You will also need to install [Homebrew](http://brew.sh) in order to install library
+dependencies.
 
-output should look like this:
+The installation of the actual dependencies is covered in the Instructions
+sections below.
 
-lib/libminiupnpc.a: Mach-O universal binary with 2 architectures
-lib/libminiupnpc.a (for architecture i386):    current ar archive random library
-lib/libminiupnpc.a (for architecture x86_64):  current ar archive random library
+Instructions: Homebrew
+----------------------
 
+#### Install dependencies using Homebrew
 
-Berkeley DB
------------
+        brew install autoconf automake libtool boost openssl pkg-config protobuf qt qrencode
 
-Download from http://freshmeat.net/projects/berkeleydb/
+#### Installing berkeley-db4 using Homebrew
 
-cd ~/bitcoin/deps
-tar xvf ~/Downloads/db-4.8.26.tar
-cd db-4.8.26/build_unix
-../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install
+The homebrew package for berkeley-db4 has been broken for some time.  It will install without Java though.
 
+Running this command takes you into brew's interactive mode, which allows you to configure, make, and install by hand:
+```
+$ brew install https://raw.github.com/mxcl/homebrew/master/Library/Formula/berkeley-db4.rb -–without-java 
+```
 
-wxWidgets
----------
+The rest of these commands are run inside brew interactive mode:
+```
+/private/tmp/berkeley-db4-UGpd0O/db-4.8.30 $ cd ..
+/private/tmp/berkeley-db4-UGpd0O $ db-4.8.30/dist/configure --prefix=/usr/local/Cellar/berkeley-db4/4.8.30 --mandir=/usr/local/Cellar/berkeley-db4/4.8.30/share/man --enable-cxx
+/private/tmp/berkeley-db4-UGpd0O $ make
+/private/tmp/berkeley-db4-UGpd0O $ make install
+/private/tmp/berkeley-db4-UGpd0O $ exit
+```
 
-This is the big one..
+After exiting, you'll get a warning that the install is keg-only, which means it wasn't symlinked to `/usr/local`.  You don't need it to link it to build novacoin, but if you want to, here's how:
 
-Check it out from svn
+    $ brew link --force berkeley-db4
 
-cd ~/bitcoin/deps
-svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk
 
-This will make a wxWidgets-trunk directory in deps.
+### Building `novacoind`
 
-Use this script snippet, change your prefix to whatever your dir is:
+1. Clone the github tree to get the source code and go into the directory.
 
-PREFIX=~/bitcoin/deps
-SRCDIR="$PREFIX/wxWidgets-trunk"
-BUILDDIR="$SRCDIR/macbuild"
+        git clone https://github.com/novacoin-project/novacoin.git
+        cd novacoin
 
-cd "$PREFIX" &&
-#svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk &&
-cd "$SRCDIR" &&
+2. Build NovaCoin-Qt application:
+        qmake
+        make
 
-[ -f include/wx/hashmap.h.orig ] || cp include/wx/hashmap.h include/wx/hashmap.h.orig &&
-sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashmap.h.orig > include/wx/hashmap.h &&
+3. Build bitcoind:
+        cd src
+        make -f makefile.osx novacoind
 
-[ -f include/wx/hashset.h.orig ] || cp include/wx/hashset.h include/wx/hashset.h.orig &&
-sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashset.h.orig > include/wx/hashset.h &&
+Use Qt Creator as IDE
+------------------------
+You can use Qt Creator as IDE, for debugging and for manipulating forms, etc.
+Download Qt Creator from http://www.qt.io/download/. Download the "community edition" and only install Qt Creator (uncheck the rest during the installation process).
 
+1. Make sure you installed everything through homebrew mentioned above 
+2. In Qt Creator do "File" -> "Open Project"
+3. Select novacoin-qt.pro as project file.
+4. In the "Projects" tab select "Manage Kits..."
+5. Select the default "Desktop" kit and select "Clang (x86 64bit in /usr/bin)" as compiler
+6. Select LLDB as debugger (you might need to set the path to your installtion)
+7. Start debugging with Qt Creator
 
+Creating a release build
+------------------------
+You can ignore this section if you are building `novacoind` for your own use.
 
-rm -vrf "$BUILDDIR" &&
-mkdir "$BUILDDIR" &&
-cd "$BUILDDIR" &&
+novacoind binary isn't included in the NovaCoin-Qt.app bundle.
 
-../configure --prefix="$PREFIX" \
---with-osx_cocoa \
---disable-shared \
---disable-debug_flag \
---with-macosx-version-min=10.5 \
---enable-stl \
---enable-utf8 \
---enable-universal_binary \
---with-libjpeg=builtin \
---with-libpng=builtin \
---with-regex=builtin \
---with-libtiff=builtin \
---with-zlib=builtin \
---with-expat=builtin \
---with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk &&
+If you are building `novacoind` or `NovaCoin-Qt` for others, your build machine should be set up
+as follows for maximum compatibility:
 
+All dependencies should be compiled with these flags:
 
-find . -name Makefile | 
-while read i; do 
-  echo $i; 
-  sed 's/-arch i386/-arch i386 -arch x86_64/g' < "$i" > "$i".new && 
-  mv "$i" "$i".old && 
-  mv "$i".new "$i"; 
-done
+ -mmacosx-version-min=10.7
+ -arch x86_64
+ -isysroot $(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
 
+Once dependencies are compiled, you can create the .dmg disk image:
 
+./contrib/macdeploy/macdeployqtplus NovaCoin-Qt.app -dmg -fancy ./contrib/macdeploy/fancy.plist
 
-make && 
-make install
+Running
+-------
 
+It's now available at `./novacoind`, provided that you are still in the `src`
+directory. We have to first create the RPC configuration file, though.
 
+Run `./novacoind` to get the filename where it should be put, or just try these
+commands:
 
-Now you should be able to build bitcoin
+    echo -e "rpcuser=novacoinrpc\nrpcpassword=$(xxd -l 16 -p /dev/urandom)" > "/Users/${USER}/Library/Application Support/NovaCoin/novacoin.conf"
+    chmod 600 "/Users/${USER}/Library/Application Support/NovaCoin/novacoin.conf"
 
-cd ~/bitcoin/trunk
-make -f makefile.osx bitcoin
+The next time you run it, it will start downloading the blockchain, but it won't
+output anything while it's doing this. This process may take several hours;
+you can monitor its process by looking at the debug.log file, like this:
 
-Before you can run it, you need to create an application bundle for Mac OS.
-Create the directories in terminal using mkdir and copy the files into place.
-They are available at http://heliacal.net/~solar/bitcoin/mac-build/
-You need the Info.plist and the .ins file.  The Contents/MacOS/bitcoin file is
-the output of the build.
-Your directory structure should look like this:
+    tail -f $HOME/Library/Application\ Support/NovaCoin/debug.log
 
-Bitcoin.app
-Bitcoin.app/Contents
-Bitcoin.app/Contents/Info.plist
-Bitcoin.app/Contents/MacOS
-Bitcoin.app/Contents/MacOS/bitcoin
-Bitcoin.app/Contents/Resources
-Bitcoin.app/Contents/Resources/BitcoinAppIcon.icns
+Other commands:
+-------
 
-To run it you can just click the Bitcoin.app in Finder, or just do open
-~/bitcoin/Bitcoin.app
-If you want to run it with arguments you can just run it without backgrounding
-by specifying the full name in terminal:
-~/bitcoin/Bitcoin.app/Contents/MacOS/bitcoin -addnode=192.75.207.66
+    ./novacoind -daemon # to start the bitcoin daemon.
+    ./novacoind --help  # for a list of command-line options.
+    ./novacoind help    # When the daemon is running, to get a list of RPC commands