Skip to content

Build.md is outdated #177

@ikripaka

Description

@ikripaka

Hi!

By now I'm figuring out how to integrate simplicity contracts with blockstream apps.

I attempted to build qt app on mac yesterday, but it was unsuccessfull.
Below are the intructions about how to build curent version of project on macOS, which was created together with my colleague.

My colleague has succeed building app macOS 15.1.1, but mine version 15.7.2 failed to build.
The last error which I encountered with on step 8 is the following.
Image

Possible steps to solve a problem:

Instruction for building on macOS

Step 1: Install Xcode Command Line Tools

xcode-select --install

Follow the prompts to install the command line tools.

Step 2: Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Add Homebrew to your PATH as instructed by the installer.

Step 3: Install Required System Dependencies

brew install cmake ninja pkg-config autoconf automake libtool gnu-sed python3
brew install boost@1.85
brew install libusb hidapi libserialport
brew install gpgme
brew install qt
brew install gnu-getopt
./tools/buildzxing.sh
brew install nlohmann-json

boost 1.84 isn't available
Note: Boost 1.85 is used as it's the latest versioned formula available in Homebrew. ZXing will be built from source in Step 5.6.

Step 4: Set Up Build Environment

Navigate to the project directory and set environment variables:

cd /path/to/green_qt
export HOST=macos
export ARCH=arm64
export PREFIX=$PWD/depends/$HOST-$ARCH
export PATH=$PREFIX/bin:$PATH

Step 5: Build Static Dependencies

Build each dependency in the correct order:

5.1 Build breakpad

./tools/buildbreakpad.sh

5.2 Build crashpad

./tools/buildcrashpad.sh

5.3 Build libusb

./tools/buildlibusb.sh

5.4 Build hidapi

./tools/buildhidapi.sh

5.5 Build countly

./tools/buildcountly.sh

5.6 Build ZXing

./tools/buildzxing.sh

5.7 Build libserialport

./tools/buildlibserialport.sh

5.8 Build KDSingleApplication

./tools/buildkdsingleapplication.sh

Step 6: Build Qt Statically

./tools/buildqt.sh

This will download and build Qt 6.8.2 with static linking. This step takes significant time and disk space.

Step 7: Build GDK (Green Development Kit)

First, fix bash syntax issues in the build scripts (macOS uses bash 3.2):

# Fix tools/buildgdk.sh
sed -i '' 's/${BUILDTYPE^}/$(echo $BUILDTYPE | tr '\''[:lower:]'\'' '\''[:upper:]'\'')/g' tools/buildgdk.sh

# Now run buildgdk.sh once to clone the GDK repository
./tools/buildgdk.sh --static

# This will fail but will clone GDK to build/gdk

# Fix GDK's internal build scripts
cd build/gdk

# Fix getopt path for Apple Silicon
sed -i '' 's|GETOPT='\''/usr/local/opt/gnu-getopt/bin/getopt'\''|if [ -f '\''/opt/homebrew/opt/gnu-getopt/bin/getopt'\'' ]; then GETOPT='\''/opt/homebrew/opt/gnu-getopt/bin/getopt'\''; else GETOPT='\''/usr/local/opt/gnu-getopt/bin/getopt'\''; fi|' tools/build.sh

# Fix bash 4+ syntax in GDK internal scripts
sed -i '' 's/${BUILDTYPE^}/$(echo $BUILDTYPE | tr '\''[:lower:]'\'' '\''[:upper:]'\'')/g' tools/build.sh
sed -i '' 's/${BUILDTYPE^}/$(echo $BUILDTYPE | tr '\''[:lower:]'\'' '\''[:upper:]'\'')/g' tools/builddeps.sh

# Fix fall-through case syntax
sed -i '' 's/;&/;;/g' tools/buildlibwally-core.sh

# Fix zlib build issue for macOS Xcode 17
sed -i '' 's/#        define fdopen(fd,mode) NULL/\/\* #        define fdopen(fd,mode) NULL *\//' tools/builddeps.sh
# Actually, this is already done above in the builddeps.sh file

cd ../..

Now build GDK:

./tools/buildgdk.sh --static
export HOST=macos && export ARCH=arm64 && export PREFIX=$PWD/depends/$HOST-$ARCH && export PATH=$PREFIX/bin:$PATH && ./tools/buildgdk.sh --static

This will take 15-30 minutes. The build compiles libwally-core, zlib, libevent, openssl, boost, and other dependencies.

Step 8: Configure the Project with CMake

After GDK is successfully built, configure the Qt application:

export HOST=macos
export ARCH=arm64
export PREFIX=$PWD/depends/$HOST-$ARCH
export CMAKE_PREFIX_PATH="/opt/homebrew/opt/boost@1.85:$PREFIX"

qt-cmake -S . -B build \
  -DCMAKE_BUILD_TYPE=Debug \
  -DGREEN_ENV=Development \
  -DGREEN_BUILD_ID=-dev \
  -DGREEN_LOG_FILE=dev \
  -DGREEN_WAYLAND=OFF \
  -DENABLE_SENTRY=OFF

Note: The GDK CMake config files should be automatically found in $PREFIX/lib/cmake/gdk after the build completes.

Step 9: Build the Application

cmake --build build --parallel 4

Step 10: Run the Application

open build/Blockstream.app

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions