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.
↧