Building GCompris-qt on macOS

in qml, qt

I recently spent way too much time compiling gcompris-qt on my mac. Eventually it came down to the following steps.

Download GCompris-qt source

GCompris is on github so the easiest first step is to git clone the repository from your terminal:

git clone https://github.com/gcompris/GCompris-qt.git

Download and install Qt

As the name suggests, GCompris-qt is written in Qt using QML. This makes the games really simple to extend and modify, and was the main reason I got into this from the beginning.

If you don't already have Qt downloading it from their website might be a bit confusing. I suggest downloading an offline installer from one of their mirrors, for example this is the link to Qt5.9.1 mac offline installer from NLUG:

http://ftp1.nluug.nl/languages/qt/official_releases/qt/5.9/5.9.1/qt-opensource-mac-x64-5.9.1.dmg

I used the default settings in the installer and had it installed in my home folder as ~/Qt5.9.1.

Fix CMakeLists.txt

As of 16/9/17 there's a small mistake in CMakeLists.txt file. One of the platform's ifdefs missed out macOS. This diff fixed the problem for me:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9ade2068..171b5b1e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -413,6 +413,9 @@ else()
     if(WIN32)
       set (_box2d_library_dir "release/")
       set (_box2d_library_file "Box2D.dll")
+    elseif(CMAKE_HOST_APPLE)
+      set (_box2d_library_dir "")
+      set (_box2d_library_file "libBox2D.dylib")
     else()
       set (_box2d_library_dir "")
       set (_box2d_library_file "libBox2D.so")

I already filed a PR and the fixed CMakeLists.txt file in full is available there. Link: https://github.com/ynonp/GCompris-qt/blob/d01151dad34ed64adf548ed11ea59a68b6def144/CMakeLists.txt.

Build

After fixing CMakeLists.txt we are ready to build:

export Qt5_DIR=~/Qt5.9.1/5.9.1/clang_64/
mkdir build
cd build
cmake ..
make

If all goes well you'll find a new bin/gcompris-qt.app/ folder with the application.

Copy Qt SVG Plugin To Result App

Another problem with the cmake definitions I did not yet address is the lack of Qt SVG plugin in the result application. The end result at least on my box was therefore unable to show any images.

The easy fix is to copy the entire imageformats plugins folder to gcompris binary. From the same build folder run:

cp -R ~/Qt5.9.1/5.9.1/clang_64/plugins/imageformats bin/gcompris-qt.app/Contents/PlugIns/

And now you have gcompris-qt and can start playing, or better yet, improving the games.

Comments