Skip to content

Instantly share code, notes, and snippets.

@gubatron
Last active October 23, 2024 00:04
Show Gist options
  • Save gubatron/f105b23a8678170bedbb4d068e67d57a to your computer and use it in GitHub Desktop.
Save gubatron/f105b23a8678170bedbb4d068e67d57a to your computer and use it in GitHub Desktop.
Building libbitcoin-network on macos with arm64 chip, clang 16

Building libbitcoin-network on macos arm64

$ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ uname -a
Darwin MBP14inchDec2021.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64

Tried doing so building boost 1.76 from source to no luck.

Next step was trying to have brew install boost 1.76 to see if we could finally configure libbitcoin-network successfully.

To do this we cloned the homebrew-core repo, and checked out the last state where it had a boost 1.76 formula

git clone https://github.com/Homebrew/homebrew-core
git checkout ce67907ee8f9fefcc1c775c82290bf0d8d75ce5a # boost: update 1.76.0 bottle. Thu Oct 21 22:21:36 2021 +0000

at this stage of the repo, the boost.rb formula lives in homebrew-core/Formula/boost.rb you can tell brew to install straight off of it

cd homebrew-core
brew install Formula/boost.rb

Then we updated the BOOST_ROOT env variable to this (it's different than if you had the sources): BOOST_ROOT=/opt/homebrew/Cellar/boost/1.76.0/include

then we go to our libbitcoin-network:

make clean
./autogen.sh
./configure CXXFLAGS="-std=c++20" --with-boost=$BOOST_ROOT --with-boost-libdir=/opt/homebrew/Cellar/boost/1.76.0/lib

We had to pass the full paths that way, otherwise it'd break

make -j10 CXXFLAGS='-std=c++20 -w -DBOOST_NO_CXX98_FUNCTION_BASE -DBOOST_ASIO_HAS_STD_INVOKE_RESULT'

That definition -DBOOST_NO_CXX98_FUNCTION_BASE avoids a compilation error with boost's hash.hpp DBOOST_ASIO_HAS_STD_INVOKE_RESULT fixes a compilation issue with boost not knowing about std::result_of

namespace boost
{
    namespace hash_detail
    {
#if defined(BOOST_NO_CXX98_FUNCTION_BASE)
        template <typename T>
        struct hash_base
	{
            typedef T argument_type;
            typedef std::size_t result_type;
        };
#else
        template <typename T>
        struct hash_base : std::unary_function<T, std::size_t> {};
#endif

Then finally...

sudo make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment