Summary
If you want to install Bitshares / graphene from source on Mac OS X Yosemite, there are a couple of gotchas not documented in the official instructions, located here:
https://github.com/cryptonomex/graphene/wiki/Building-on-OS-X
In my case, if I followed those instructions, I got compile errors. Here's what worked for me instead. I put the error messages observed below, so that this is more visible to search engines.
Compiling Bitshares from source on Mac OS X Yosemite (10.5.5).
Install XCode and its command line tools by following the instructions here: https://guide.macports.org/#installing.xcode. In OS X 10.11 (El Capitan) and newer, you will be prompted to install developer tools when running a devloper command in the terminal. This step may not be needed.
Install Homebrew by following the instructions here: http://brew.sh/
Initialize Homebrew:
brew doctor
brew update
- Install dependencies:
brew install cmake git openssl autoconf automake berkely-db google-perftools
- Install boost160
brew install homebrew/versions/boost160
Note that you'll see this warning:
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.
Conflicts with boost
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/boost160/lib
CPPFLAGS: -I/usr/local/opt/boost160/include
==> Summary
�� /usr/local/Cellar/boost160/1.60.0: 11,139 files, 436.8M
- Clone the Graphene repository:
git clone https://github.com/cryptonomex/graphene.git
cd graphene
- Build BitShares:
git submodule update --init --recursive
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include -DBOOST_ROOT=/usr/local/opt/boost160 -DBOOST_LIBRARYDIR=/usr/local/opt
make
Troubleshooting the Bitshares compile process
Homebrew refuses to link to the Homebrew version of OpenSSL. During openssl install, Homebrew will give this error message:
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
If you try to force brew to link to OpenSSL, you get this error message:
crasch$ brew link --force openssl
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
If you try to make anyway, you'll get this error message:
CMake Error at /usr/local/Cellar/cmake/3.6.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES) (found
version "0.9.8}")
To work around this, you have to explicitly pass the location of the OPENSSL_ROOT_DIR and OPENSSL_INCLUDE_DIR directories to the Cmake command. If you're successful, you'll see something like this in the compile output:
-- OPENSSL_FOUND = TRUE
-- OPENSSL_INCLUDE_DIR = /usr/local/opt/openssl/include
-- OPENSSL_LIBRARIES = /usr/local/opt/openssl/lib/libssl.a;/usr/local/opt/openssl/lib/libcrypto.a
-- OPENSSL_VERSION = 1.0.2h
Next, the latest boost package conflicts with this version of graphene. If you try to build with the last boost package, you get this compile error:
user-users-iMac:graphene crasch$ make install
[ 5%] Built target udt
[ 8%] Built target project_secp256k1
[ 8%] Building CXX object libraries/fc/CMakeFiles/fc.dir/src/thread/thread.cpp.o
In file included from /Users/crasch/src/graphene/libraries/fc/src/thread/thread.cpp:5:
In file included from /Users/crasch/src/graphene/libraries/fc/src/thread/thread_d.hpp:5:
/Users/crasch/src/graphene/libraries/fc/src/thread/context.hpp:215:9: error: no type named 'fcontext_t' in namespace
'boost::context'
bc::fcontext_t my_context;
~~~~^
/Users/crasch/src/graphene/libraries/fc/src/thread/context.hpp:69:23: error: no member named 'make_fcontext' in
namespace 'boost::context'
my_context = bc::make_fcontext( stack_ctx.sp, stack_ctx.size, sf);
~~~~^
In file included from /Users/crasch/src/graphene/libraries/fc/src/thread/thread.cpp:5:
/Users/crasch/src/graphene/libraries/fc/src/thread/thread_d.hpp:401:17: error: no member named 'jump_fcontext' in
namespace 'boost::context'; did you mean 'boost::context::detail::jump_fcontext'?
bc::jump_fcontext( &prev->my_context, next->my_context, 0 );
^~~~~~~~~~~~~~~~~
boost::context::detail::jump_fcontext
/usr/local/include/boost/context/detail/fcontext.hpp:31:35: note: 'boost::context::detail::jump_fcontext' declared
here
transfer_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t const to, void * vp);
^
In file included from /Users/crasch/src/graphene/libraries/fc/src/thread/thread.cpp:5:
/Users/crasch/src/graphene/libraries/fc/src/thread/thread_d.hpp:443:17: error: no member named 'jump_fcontext' in
namespace 'boost::context'; did you mean 'boost::context::detail::jump_fcontext'?
bc::jump_fcontext( &prev->my_context, next->my_context, (intptr_t)this );
^~~~~~~~~~~~~~~~~
boost::context::detail::jump_fcontext
/usr/local/include/boost/context/detail/fcontext.hpp:31:35: note: 'boost::context::detail::jump_fcontext' declared
here
transfer_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t const to, void * vp);
^
4 errors generated.
make[2]: *** [libraries/fc/CMakeFiles/fc.dir/src/thread/thread.cpp.o] Error 1
make[1]: *** [libraries/fc/CMakeFiles/fc.dir/all] Error 2
make: *** [all] Error 2
To work around, you have to install the boost160 package instead, and explicitly pass the location of the BOOST_ROOT BOOST_LIBRARYDIR directories to the Cmake command.