Skip to content

Instantly share code, notes, and snippets.

@awesome-doge
Last active February 11, 2023 11:45
Show Gist options
  • Save awesome-doge/9bfbd1d3fd9b725c4df224433fa3596e to your computer and use it in GitHub Desktop.
Save awesome-doge/9bfbd1d3fd9b725c4df224433fa3596e to your computer and use it in GitHub Desktop.

The correct way, install homebrew on apple m1.

# We'll be installing Homebrew in the /opt directory.
cd /opt

# Create a directory for Homebrew. This requires root permissions.
sudo mkdir homebrew

# Make us the owner of the directory so that we no longer require root permissions.
sudo chown -R $(whoami) /opt/homebrew

# Download and unzip Homebrew. This command can be found at https://docs.brew.sh/Installation.
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

# Add the Homebrew bin directory to the PATH. If you don't use zsh, you'll need to do this yourself.
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc

pip3 install ds_store mac_alias

Download the Bitcoin code

# Download bitcoin/bitcoin on Github.
git clone https://github.com/bitcoin/bitcoin

# Switch to the bitcoin folder
cd bitcoin/

Compilation tool for apple m1

cd depends/
make
# After completing this step, you will see one more folder (arm-apple-darwin20.2.0) in /bitcoin/depends.
# Go back to bitcoin folder
cd ..

./autogen.sh

# Set up the compilation tool
./configure --prefix=$PWD/depends/arm-apple-darwin20.2.0

# https://github.com/bitcoin/bitcoin/tree/master/depends

# Start to compile bitcoin
make HOST=arm-apple-darwin20

make check

make deploy
@pdxrod
Copy link

pdxrod commented May 1, 2021

I didn't find it that easy

One thing I had to add to the above, was, after cd depends/, you need to make with an argument to make it create the arm-apple-darwin20... folder - the main make command still failed:

  # Ensure your ~/.zshrc file contains export ARCHFLAGS="-arch arm64"
    mkdir bitcoin
    cd bitcoin
    git clone https://github.com/bitcoin/bitcoin
    cd bitcoin
# Ensure qt.mk has what it says here: https://github.com/bitcoin/bitcoin/pull/20482/files
    arch -arm64 brew install automake libtool boost pkg-config libevent
    arch -arm64 brew reinstall sqlite
    arch -arm64 brew install qt@5
    arch -arm64 brew install librsvg
    export BOOST_ROOT=/opt/homebrew/opt/boost
    export LIBEVENT=/opt/homebrew/opt/libevent
    export HOST=arm-apple-darwin20.3.0
    ./autogen.sh
    cd depends/
    make HOST=$HOST
    ls
        ... arm-apple-darwin20.3.0 ...
    cd ..
   ./configure --prefix=$PWD/depends/$HOST --without-bdb --with-boost=$BOOST_ROOT CPPFLAGS="-I$LIBEVENT" --disable-wallet
   make HOST=$HOST

I needed all those configure flags to enable configure to run without error.
But make produced

 ld: warning: ignoring file /opt/homebrew/opt/boost/lib/libboost_filesystem.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64ignoring file /opt/homebrew/opt/boost/lib/libboost_system.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
...
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bitcoind] Error 1

No matter how many ways I tried to make 'boost' in ARM-64 code

@sushantkumar23
Copy link

@pdxrod - This was so helpful

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