Skip to main content
Skip table of contents

Qt Creator and Mako (Windows)


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:

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

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:

CODE
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

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:

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

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.

CODE
CONFIG += c++14

Complete Qmake example

This file is taken from a working project.

CODE
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


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.