How to use qt5 static library?



  • I checked out qt5.7.0 source code from git via the following command

    $ git clone https://code.qt.io/qt/qt5.git # cloning the repo
    $ cd qt5
    $ git checkout v5.7.0 # checking out the specific release or branch
    $ git submodule update --init # updating each submodule

    and built successfully via the following command

    D:\JandunWork\qt5> configure.bat -prefix C:\Qt\Qt570_Static -static -debug-and-release -openssl -I C:\Libs\openssl_1.0.1j\include -L C:\Libs\openssl_1.0.1j\lib -opensource -confirm-license -make libs -nomake examples -nomake tests
    D:\JandunWork\qt5> nmake
    D:\JandunWork\qt5> nmake install

    Question One


    How to configure my Visual Studio 2015 or Qt Creator to program with qt5.7.0 static library? What I mean is that after I configure Visual Studio 2015 or Qt Creator I can simply create qt project via visual operation File>New>Project based on qt static library I built. It is as simple as using dynamic qt library installed from official setup.

    I can build my static qt application by adding include path, library path and library name for every project in Visual Studio 2015 for every new project or by executing qmake *pro; nmake in command prompt.

    Question Two


    As you know, I can build my static qt application via

    D:\JandunWork\Qt570StaticTestProject> qmake test.pro
    D:\JandunWork\Qt570StaticTestProject> nmake

    Oddities happened to qt quick project while qt widget project worked well.
    When I only use Rectangle QML Type, I got something like
    Rectangle.

    It looks well, but when I tried to resize it, it became something like
    Resize Rectangle.

    What's worse, ApplicationWindow and Window QML Type cannot be rendered and I just got
    Window.

    So what's wrong with qt quick module from my static qt library? Or is it because I didn't use it in correct way?

    If necessary I can provide with more information about my qt build configuration and test cases. Thanks for your patience. Any help is appreciated.


  • Lifetime Qt Champion

    Hi,

    You need to go to the settings. Add a new Qt version pointing to your static build and create a Kit to use it.

    You should rather clone the latest 5.7, that way you'll have the bug fixes that went it in between.



  • @SGaist said in How to use qt5 static library?:

    Hi,

    You need to go to the settings. Add a new Qt version pointing to your static build and create a Kit to use it.

    You should rather clone the latest 5.7, that way you'll have the bug fixes that went it in between.

    I had add Qt570_Static version manually as the following picture shows.
    0_1473173928693_Qt570StaticVersion.png

    Please pay attention to the sentence No qmlscene installed. I have no idea whether it matters.

    After I added Qt570_Static version, there is a default kit as the following picture shows.
    0_1473173943536_Qt570StaticKit.png

    Obviously, there is something missing about this kit.

    I create two project with this kit, but there are link errors when building.0_1473173405383_Qt570StaticProjectBuild.png

    Any advanced advice? Thank you in advance.


  • Lifetime Qt Champion

    qmlscene is a helper tool which is not mandatory to build your applications.

    AFAIK, that's a library from the DirectX SDK.



  • @SGaist said in How to use qt5 static library?:

    qmlscene is a helper tool which is not mandatory to build your applications.

    AFAIK, that's a library from the DirectX SDK.

    Thank you for your reply.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.