Skip to content

Instantly share code, notes, and snippets.

@raffecat
Last active November 14, 2022 06:12
Show Gist options
  • Save raffecat/5348704fc9b8a7938422ea44386a764d to your computer and use it in GitHub Desktop.
Save raffecat/5348704fc9b8a7938422ea44386a764d to your computer and use it in GitHub Desktop.
Building Dogecoin Core on M1 mac
# MacBook Air M1 2020, macOS 12.5.1 Monterey, XCode 14.1
# https://github.com/dogecoin/dogecoin/blob/master/doc/Building-Dogecoin-1.14-for-Mac.md
# https://github.com/dogecoin/dogecoin/blob/master/doc/build-osx.md
git clone git@github.com:dogecoin/dogecoin.git
cd dogecoin
git checkout tags/v1.14.6
brew install boost --build-from-source --HEAD # per Building-Dogecoin-1.14-for-Mac.md
brew install autoconf automake libtool miniupnpc pkg-config protobuf qt5 zeromq qrencode librsvg libevent openssl@1.1
brew install berkeley-db@5 # You need to make sure you install a version >= 5.3.28, but as close to 5.3.28 as possible.
# more homebrew BS… https://github.com/Homebrew/brew/issues/12879
# `brew --prefix openssl` returns the path to openssl@3 – EVEN IF it's not installed!
# libevent depends on openssl@1.1 and `brew install openssl` installs openssl@3
# however, the Dogecoin Core tests FAIL when compiled with openssl@3 (seems to be OldDecrypt)
# so now I have to symlink openssl@3 to openssl@1.1 (because the configure script uses `brew --prefix openssl`)
ln -s /opt/homebrew/opt/openssl@1.1 `brew --prefix openssl`
# `brew --prefix berkeley-db` returns the wrong path when berkeley-db@5 is installed (as above)
ln -s /opt/homebrew/opt/berkeley-db@5 `brew --prefix berkeley-db`
# this is what I ended up using…
export LDFLAGS="-L/opt/homebrew/opt/boost/lib -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/qt@5/lib -L/opt/homebrew/opt/berkeley-db@5/lib"
export CPPFLAGS="-I/opt/homebrew/opt/boost/include -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/qt@5/include -I/opt/homebrew/opt/berkeley-db@5/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig:/opt/homebrew/opt/qt@5/lib/pkgconfig"
export BOOST_ROOT="/opt/homebrew/opt/boost"
export BOOST_LIBRARYDIR="/opt/homebrew/opt/boost/lib"
export BOOST_LDFLAGS="-L/opt/homebrew/opt/boost/lib"
export BOOST_CPPFLAGS="-I/opt/homebrew/opt/boost/include"
# some compile errors due to different std lib implementations…
# src/net.h ~ add: #include <array>
# src/cuckoocache.h ~ add: #include <deque>
./autogen.sh
./configure
make
make check
@raffecat
Copy link
Author

raffecat commented Nov 8, 2022

Options used to compile and link:
  with wallet   = yes
  with gui / qt = yes
    qt version  = 5
    with qr     = yes
  with zmq      = yes
  with test     = yes
  with bench    = yes
  with upnp     = auto
  debug enabled = no
  werror        = no

  target os     = darwin
  build os      = darwin

  CC            = gcc
  CFLAGS        = -g -O2
  CPPFLAGS      = -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/qt@5/include -I/opt/homebrew/opt/berkeley-db@5/include -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -I/opt/homebrew/opt/berkeley-db/include -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0
  CXX           = g++ -std=c++11
  CXXFLAGS      = -g -O2 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter -Wno-self-assign -Wno-unused-local-typedef -Wno-deprecated-register
  LDFLAGS       = -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/qt@5/lib -L/opt/homebrew/opt/berkeley-db@5/lib -Wl,-headerpad_max_install_names -Wl,-dead_strip

@raffecat
Copy link
Author

raffecat commented Nov 8, 2022

raffe@Andrews-Air libdogecoin % gcc --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

@raffecat
Copy link
Author

raffecat commented Nov 14, 2022

# Ubuntu arm64 on M1  (mounts mac home dir)

brew install --cask multipass
multipass launch
multipass shell   # start, stop, list, find, launch <image>, info, delete, purge

See also: https://multipass.run/docs/create-an-instance

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