Blockstream / Blockstream/green_qt

`Build.md` is outdated

Open
#177 1 comment 2 reactions 1 assignee Claimed by @ardier16 View on GitHub
documentation status: awaiting-reporter
Dominant language
C++
Stars
262
Forks
44
PR merge metrics
No merged PRs in 30d

Description

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:
* update `Build.md` file
* fix AGL removal by Apple (https://github.com/azahar-emu/azahar/issues/1188)
(version of qt has to be bumped at least to 6.9.3)
* move usage of `getopt` util from `/usr/local/opt/gnu-getopt/bin/getopt` path to `/usr/bin/getopt` on M chip macs
* specify version of macOS that is suitable for builds

# Instruction for building on macOS

## Step 1: Install Xcode Command Line Tools

```bash
xcode-select --install
```

Follow the prompts to install the command line tools.

## Step 2: Install Homebrew

```bash
/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

```bash
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:

```bash
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

```bash
./tools/buildbreakpad.sh
```

### 5.2 Build crashpad

```bash
./tools/buildcrashpad.sh
```

### 5.3 Build libusb

```bash
./tools/buildlibusb.sh
```

### 5.4 Build hidapi

```bash
./tools/buildhidapi.sh
```

### 5.5 Build countly

```bash
./tools/buildcountly.sh
```

### 5.6 Build ZXing

```bash
./tools/buildzxing.sh
```

### 5.7 Build libserialport

```bash
./tools/buildlibserialport.sh
```

### 5.8 Build KDSingleApplication

```bash
./tools/buildkdsingleapplication.sh
```

## Step 6: Build Qt Statically

```bash
./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):

```bash
# 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:

```bash
./tools/buildgdk.sh --static
```

```bash
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:

```bash
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

```bash
cmake --build build --parallel 4
```

## Step 10: Run the Application

```bash
open build/Blockstream.app
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.