Important: Please read the Qt Code of Conduct -

How to link against the QTTest

  • Hi,

    I have some linking problems when using QTTest framework
    I want to make a QML test and I use the QTTest framework with QTCreator. In the QML file I have the "import QtTest 1.1" statement, and the IDE recognizes the "TestCase" element, so it shall be fine.

    I set the main.cpp function as it was written in the tutorial


    The problem is: it does not find the method in any of the linked libraries.

    main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl quick_test_main(int,char * *,char const ,char const *)" (__imp_?quick_test_main@@YAHHPEAPEADPEBD1@Z) referenced in function main

    my .pro file looks like, so I guess this symbol shall be in the "testllib" somewhere. In the documentation I did not find anything that would point to the right library to use. The only info I found was this tutorial ( and it uses the "testlib"

    QT += qml quick testlib
    SOURCES += main.cpp \
    RESOURCES += qml.qrc
    HEADERS += \
    TARGET = tst_example
    CONFIG += warn_on qmltestcase

    Does anyone has an idea how to link it correctly? Thank you!


  • Someone told me the answer: I had to run "Build/Run qmake". After that it works ok.
    I wonder why I need that? What does that mean? Will it reconfigure my make files?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    It's because you modified your pro file. Running qmake after that will refresh the Makefiles with the needed content to build your project correctly.

Log in to reply