Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using Qt Headers on Static Library
Qt 6.11 is out! See what's new in the release blog

Using Qt Headers on Static Library

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maydin
    wrote on last edited by
    #1

    I created a subdirs project. I have 2 subproject called "app" and "engine". engine is a static library, and i want to use it from my app. But I cannot include Qt libraries like "<QStack>" in engine.

    It works if I include in app but not in my static library?

    K 1 Reply Last reply
    0
    • M maydin

      I created a subdirs project. I have 2 subproject called "app" and "engine". engine is a static library, and i want to use it from my app. But I cannot include Qt libraries like "<QStack>" in engine.

      It works if I include in app but not in my static library?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @maydin

      How did you create the .pro-file for the static library?

      It should be similar to the .pro of your application. The main difference is sthat you are using a different template in there.
      You need to declare also all Qt modules required as in your .pro for template app.

      The subdirs template basically bundles a couple of .pro and allows to build at once. Therefore your .pro for teh static library has to be self-contained.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1
      • M Offline
        M Offline
        maydin
        wrote on last edited by maydin
        #3

        @koahnig

        Edit: I realized wizard removes core from pro file. When i added core to Qt by using Qt += core it worked. Now i have different problems like unresolved references.

        I created from Qt Creator inside. Right clicked to project, "New Subroject" and selected static library. I compared .pro files from other classic projects but couldn't find a huge different except template. I do not see any library that starts with Q if i want to include.
        Here is my .pro file for static lib:

        **QT       -= core gui**
        TARGET = engine
        TEMPLATE = lib
        CONFIG += staticlib
        CONFIG += c++11
        
        DEFINES += QT_DEPRECATED_WARNINGS
        
        SOURCES += \
                coreclass.cpp \
        
        HEADERS += \
                coreclass.h \
        
        unix {
            target.path = /usr/lib
            INSTALLS += target
        }
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          @maydin said in Using Qt Headers on Static Library:

          QT -= core gui

          Since you remove core and gui, you won't be able to use any of Qt's classes provided by these module.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved