# C++

Although Mavericks is required for compiling the app, the app has been tested to run on 10.8, 10.9 and 10.10.

## Build with Homebrew <a href="#build-with-homebrew" id="build-with-homebrew"></a>

For the stable branch:

```
brew tap lattice/lattice
brew install cpp-lattice --build-from-source
brew linkapps cpp-lattice
```

For the development branch:

```
brew reinstall cpp-lattice --devel --build-from-source
brew linkapps cpp-lattice
```

Add the `--with-gui` option to also build AlethZero and the Mix IDE.

Then `open /Applications/AlethZero.app`, `eth` (CLI) or `neth` (ncurses interface)

For options and patches, see: [https://github.com/lattice/homebrew-lattice](https://github.com/lattice/homebrew-lattice)

## Manual Build <a href="#manual-build" id="manual-build"></a>

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* Latest Xcode on Mavericks (at least Xcode 5.1+).
* Homebrew package manager [http://brew.sh](http://brew.sh/) _or_ MacPorts package manager [http://macports.org](http://macports.org/)
* XQuartz [http://xquartz.macosforge.org/landing/](http://xquartz.macosforge.org/landing/)

## Install dependencies <a href="#install-dependencies" id="install-dependencies"></a>

Using homebrew:

```
brew install boost --c++11 # this takes a while
brew install boost-python --c++11
brew install cmake qt5 cryptopp miniupnpc leveldb gmp libmicrohttpd libjson-rpc-cpp
```

Or, using MacPorts:

```
port install boost +universal # this takes a while
port install cmake qt5-mac libcryptopp miniupnpc leveldb gmp
(probably missing libmicrohttpd and libjson-rpc-cpp)
```

## Clone source repo and create build folder <a href="#clone-source-repo-and-create-build-folder" id="clone-source-repo-and-create-build-folder"></a>

```
git clone https://github.com/lattice/cpp-lattice.git
cd cpp-lattice
mkdir -p build # create build folder ('build' ignored by git)
```

## Compile <a href="#compile" id="compile"></a>

```
cd build
cmake ..
make -j6
make install
```

This will also install the cli tool and libs into /usr/local.

## XCode Instructions <a href="#xcode-instructions" id="xcode-instructions"></a>

From the project root:

```
mkdir build_xc
cd build_xc
cmake -G Xcode ..
```

This will generate an xcode project file along with some configs for you: lattice.xcodeproj . Open this file in XCode and you should be able to build the project

## Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

Linking errors can usually be resolved by ensuring correct paths:

```
export LIBRARY_PATH=/opt/local/lib # this is MacPorts's default
```

Make sure your `macdeployqt` can be found. Lattice expects it to be in `/usr/local/opt/qt5/bin/macdeployqt` so symlink it if it's not:

```
ln -s `which macdeployqt` /usr/local/opt/qt5/bin/macdeployqt
```

If you're not planning to develop, make sure you are building from the master branch, not from develop or any others. These branches can often be broken or have other requirements.
