Skip to content

Build OpenBoard on MacOS (Universal)

kaamui edited this page Jan 2, 2024 · 10 revisions

⚠️ Disclaimer ⚠️

Universal building is not supported before Qt 5.15.10, which is at this point only available with a commercial license. For now, these instructions are made to work with Qt 6, and were not tested with Qt 5.15.10. We recommend the use of Qt 6.5

Prepare your environment

Install XCode

Install Xcode via Apple Store. Then, open a terminal and run the following command :

xcode-select --install

sudo xcodebuild -license

Install MacPorts

Go to https://www.macports.org/install.php and pick the package corresponding to the version of your OS.

Once downloaded, double click on it and follow the instructions to install it. Then, go to your terminal and run :

sudo port -v selfupdate
sudo port upgrade outdated

Install Qt

If you already have Qt and added Qt bin path to PATH, you can go to the next section.

Download Qt

Qt WebEngine is built using Qt, so we need to install Qt 6.

Download Qt installer from this page : https://www.qt.io/download-qt-installer

Open it and follow the instructions.

Select the Qt version you want to install. For this wiki, we'll use the Qt 6.3.2 version, and we simply select :

  • macOS

Note that for this example, Qt was installed in user's home directory (i-e /Users/username/Qt)

Add Qt bin path to PATH

Open /etc/paths in your favorite text editor, and add the following entry (adapted to the path you chose to install Qt in) :

/Users/username/Qt/6.3.2/macOS/bin

Follow the instructions and pick the <Qt_version> you want (for example 6.3.2). You'll need :

  • Desktop gcc 64-bit
  • Qt Multimedia
  • Qt Positioning
  • Qt WebChannel
  • Qt 5 Compatibility Module
  • Qt Debug Information Files (recommended but not mandatory)

Add qmake to environment variables

Open /etc/paths in a text editor with administrator rights :

sudo nano /etc/paths

And add the following line (the location of the qmake binary, when installed with macports) :

/opt/local/libexec/qt5/bin

Install OpenBoard dependencies

At the time you are reading this page, using macports to install quazip and poppler with +universal won't work, because of a boost issue. So we need to compile them by our own. For every other library that may be necessary to build OpenBoard, you can install it using MacPorts, using the universal variant, i.e sudo port install ffmpeg +universal

sudo port install qt5 +universal
sudo port install ffmpeg +universal
sudo port install cairo +universal
sudo port install openjpeg +universal
sudo port install fontconfig +universal
sudo port install nss +universal
sudo port install curl +universal
sudo port install freetype +universal
sudo port install jpeg +universal

Build boost universal

git clone --recursive https://github.com/boostorg/boost.git
cd boost
git checkout develop # or whatever branch you want to use

Create a script called build.sh, containing this :

#!/bin/sh

rm -rf arm64 x86_64 universal stage bin.v2
rm -f b2 project-config*
./bootstrap.sh cxxflags="-arch x86_64 -arch arm64" cflags="-arch x86_64 -arch arm64" linkflags="-arch x86_64 -arch arm64"
./b2 toolset=clang-darwin target-os=darwin architecture=arm abi=aapcs cxxflags="-arch arm64" cflags="-arch arm64" linkflags="-arch arm64" -a
mkdir -p arm64 && cp stage/lib/*.dylib arm64
./b2 toolset=clang-darwin target-os=darwin architecture=x86 cxxflags="-arch x86_64" cflags="-arch x86_64" linkflags="-arch x86_64" abi=sysv binary-format=mach-o -a
mkdir x86_64 && cp stage/lib/*.dylib x86_64
mkdir universal
for dylib in arm64/*; do 
  lipo -create -arch arm64 $dylib -arch x86_64 x86_64/$(basename $dylib) -output universal/$(basename $dylib); 
done
for dylib in universal/*; do
  lipo $dylib -info;
done

Launch it.

sudo ./build.sh

Build Poppler universal

git clone https://github.com/freedesktop/poppler.git

cd poppler
mkdir build
cd build

cmake .. -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DCMAKE_INSTALL_PREFIX=/opt/local -DCMAKE_INSTALL_NAME_DIR=/opt/local/lib -DENABLE_UNSTABLE_API_ABI_HEADERS=ON -DENABLE_QT5=OFF -DENABLE_CPP=OFF -DENABLE_QT6=OFF -DENABLE_GLIB=OFF
make -j8
sudo make install 

Build Quazip universal

git clone https://github.com/stachenov/quazip.git

cd quazip
mkdir build
cd build

cmake .. -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DQUAZIP_QT_MAJOR_VERSION=6 -DCMAKE_INSTALL_PREFIX=/opt/local -DCMAKE_INSTALL_NAME_DIR=/opt/local/lib
make
sudo make install

Download OpenBoard sources

# place yourself in the directory you want 
# (in this example at user's home directory)
cd

# create the folder
mkdir openboard

# enter in it
cd openboard

# Download OpenBoard sources
git clone https://github.com/OpenBoard-org/OpenBoard.git

# place yourself on the dev branch
cd OpenBoard
git checkout dev

Compile OpenBoard

Then, go to OpenBard's directory

cd <path_to_openboard>
cd Openboard

Open the OpenBoard.pro file, and check that the following parameter is correctly set :

# For universal builds
# QMAKE_APPLE_DEVICE_ARCHS=x86_64 arm64 

Thus, Qt will build OpenBoard as a universal binary.

You can now compile OpenBoard :

qmake OpenBoard.pro
make

Package OpenBoard

Go the the release_scripts directory :

cd release_scripts/osx

Edit qmake path in build.sh and package.sh

Now, we need to edit the scripts to define where qmake is located. Open build.sh and package.sh and change the value of BASE_QT_DIR to :

BASE_QT_DIR=/opt/local/libexec/qt5

Execute the scripts

When you want to package a new version of OpenBoard, you have 4 scripts to execute, to create a fully built, packaged, signed and notarized application. Note that you need an Apple developer account to sign and notarize your app. :

sudo ./build.sh
sudo ./codesign.sh "Developer ID Application : ..." # <= you need to replace the parameter by your own certificate
sudo ./package.sh
sudo ./notarize.sh "emailUsedForYourAppleDevAccount@email.com"

Now, you should see your OpenBoard installer in <path_to_openboard>/Openboard/install/macos>

Clone this wiki locally