Important: Please read the Qt Code of Conduct -

Non Qt application linking Qt library

  • Hello,

    I have a Qt based library. And I want to link with non Qt application.

    When I link it, the linkers get mad about Qt libraries. It expects me to link Qt libraries as well.

    Is this an expected behaviour?

    Can I not just link only the library I want?


  • Could it be possible you share your Qt library project file? I guess your library will depend at least on Qt Core

  • @Pablo-J.-Rogina


    Here is the pro file content.

    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET          = uicore
    TEMPLATE        = lib
    CONFIG         += staticlib
    # Find the built application here..
    DESTDIR         = ../lib

    Yes, as you mentioned, my library depends on Qt Core and Qt Gui.

    I understand that my library needs these Qt libraries.

    But, I am trying to avoid linking Qt libraries for the non Qt application.

  • I understand that for 'staticlib' to work, you first have to build Qt statically. You may want to take a look at this post.
    And please also consider that using Qt statically is very likely that require a commercial license for Qt. There's much debate about LGPL and static linking, you may need some legal advice in that case. I guess this post is a good starting point to understand the possible cases

Log in to reply