Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Another static library issue. [solved]

Another static library issue. [solved]

Scheduled Pinned Locked Moved Installation and Deployment
4 Posts 2 Posters 1.6k Views 1 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.
  • H Offline
    H Offline
    heliosbird
    wrote on last edited by
    #1

    I followed this guide for creating and using a static library in Qt:
    https://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application

    I have a class that I would like to use in Matlab, so I would like to create a static library. I am using Qt 4.8.0, statically compiled, commercial on a Windows 7 machine.

    I created a project for the library:
    @
    QT += network
    TEMPLATE = lib
    CONFIG+= staticlib

    Input

    INCLUDEPATH += ../common/output
    ../common/input
    ../common/core
    ../common/crc

    HEADERS += ../common/output/imageUdpSender.h
    ../common/input/image.h
    ../common/core/coreModule.h
    ../common/input/internalProtocol.h
    ../common/output/testState.h
    ../common/crc/crc.h

    SOURCES += ../common/output/imageUdpSender.cpp
    ../common/core/coreModule.cpp
    ../common/output/testState.cpp
    ../common/crc/crc.cpp

    INTF_VERSION = 2
    INTF_VERSTR = '\"$${INTF_VERSION}\"'
    DEFINES += INTERFACE_VERSION="$${INTF_VERSTR}"

    TARGET = ../../../ShutterSoftware/build/Library

    static { # everything below takes effect with CONFIG += static
    TARGET = ../../../../../ShutterSoftware/build/static/Library
    CONFIG += static
    QTPLUGIN += qsvg qico #qpng # image formats
    DEFINES += STATIC
    message("~~~ static build ~~~") # this is for information, that the static build is done
    mac: TARGET = $$join(TARGET,,static,_static) #this adds an _static in the end, so you can seperate static build from non static build
    win32: TARGET = $$join(TARGET,,static,s) #this adds an s in the end, so you can seperate static build from non static build
    }
    @

    The above project creates a *.lib. However, when I tried to include it in a project, I get this error:

    @C:\Users\IKOMED6\Documents\SVN\Software\ShutterControlGUI\Qt\ShutterSoftware\ShutterUILibrary\TestLibrary\main.cpp:2: error: C1083: Cannot open include file: 'imageUdpSender.h': No such file or directory@

    The project file for the project trying to use the library:

    @QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = TestLibrary
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    INCLUDEPATH += $$PWD/../../build/static
    LIBS += -static -L$$PWD/../../build/static/ -lLibrarys.lib

    TARGET = ../../../ShutterSoftware/build/TestLibrary

    static { # everything below takes effect with CONFIG += static
    TARGET = ../../../../../ShutterSoftware/build/static/TestLibrary
    CONFIG += static
    QTPLUGIN += qsvg qico #qpng # image formats
    DEFINES += STATIC
    message("~~~ static build ~~~") # this is for information, that the static build is done
    mac: TARGET = $$join(TARGET,,static,_static) #this adds an _static in the end, so you can seperate static build from non static build
    win32: TARGET = $$join(TARGET,,static,s) #this adds an s in the end, so you can seperate static build from non static build
    }
    @

    and the main.cpp is extremely simple (I only made this project to test the .lib):

    @#include "mainwindow.h"
    #include "imageUdpSender.h"

    int main(int argc, char *argv[])
    {

    }@

    I'm not sure what is wrong... how do I even know if the *.lib was created properly? I've tried everything I've found online, so I'm at a loss...

    Thanks in advance.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Currently, you're not even linking to your library, what you have is an INCLUDEPATH problem. Where is "imageUdpSender.h" located ?

      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
      0
      • H Offline
        H Offline
        heliosbird
        wrote on last edited by
        #3

        Thanks for your speedy reply! The imageUdpSender.h is located in common/output, which I have in the include path: ../common/output

        Now, I originally thought this was the issue, but when I comment out image.h (which is included in imageUdpSender.h), the Library project will not compile and states it is missing image.h. To me, this indicated that I am linking to the library in Library.pro, but I guess I'm wrong.

        Here is the folder structure, I hope this makes sense.

        Project Folder
        -common
        --input
        --output
        --core
        --crc
        -build
        --static
        ---Librarys.lib # not a typo
        -Library (Project to create static library)
        --library.pro (ie. first .pro above)
        -TestLibrary (Project to test above static library)
        --Test.pro (ie. second .pro above)
        --main.cpp (above)

        1 Reply Last reply
        0
        • H Offline
          H Offline
          heliosbird
          wrote on last edited by
          #4

          I had a fundamental misunderstanding about static libraries. I think I have it cleared up now, thanks.

          1 Reply Last reply
          0

          • Login

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