Created Date: 26 Jan, 2022 14:22
Last Modified Date: 26 Jan, 2022 14:27


Qt compiler

The Mako libraries for Windows are built with MSVC 2019, so Qt needs to be configured to use this compiler rather than the default of MinGw. One way to do this is to choose the option at installation time, for example:

The following information applies to Qmake, and should be adapted if you are using CMake as your build configurator.

Mako headers

Add these to the include path, for example:

INCLUDEPATH += $$_PRO_FILE_PWD_/../mako-win-vc16-static-all/interface
CODE

Here, I use the macro that identifies the folder containing the project, as I chose to locate the Mako library folder alongside the project folder. Where they are located in your environment is up to you.

Mako library

Add Mako.lib, plus some additional Windows libraries that are required for Mako, as follows:

LIBS += $$_PRO_FILE_PWD_/../mako-win-vc16-static-all/libs/debugstatic-win-x64-vc16/mako.lib
LIBS += ws2_32.lib rpcrt4.lib Advapi32.lib User32.lib
CODE

Note that there are separate Mako lib files for debug and release builds. The latter is preferred for production code, as it runs faster.

Compiler switches

In this case, the statically-linked build of Mako is specified, which means that the resulting executable is standalone and does not rely on a runtime library. However, some compiler flags must be specified, as follows:

QMAKE_CXXFLAGS_RELEASE = -O2 -MT -MP2
QMAKE_CXXFLAGS_DEBUG = -Zi -MTd -MP2
CODE

As you see, there are different flags according to the build type, debug or release. The defaults of -MD (or -MDd for debug) are good for the dynamically-linked build of Mako.

C++ Version

Include this to your Qmake file, as C++14 is the version we use to build Mako. All our sample apps are configured for that too.

CONFIG += c++14
CODE

Complete Qmake example

This file is taken from a working project.

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++14

#message("You are here" $$_PRO_FILE_PWD_)

QMAKE_CXXFLAGS_RELEASE = -O2 -MT -MP2
QMAKE_CXXFLAGS_DEBUG = -Zi -MTd -MP2

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

INCLUDEPATH += $$_PRO_FILE_PWD_/../mako-win-vc16-static-all/interface
LIBS += $$_PRO_FILE_PWD_/../mako-win-vc16-static-all/libs/debugstatic-win-x64-vc16/mako.lib
LIBS += ws2_32.lib rpcrt4.lib Advapi32.lib User32.lib

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

FORMS += \
    mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

CODE