Building shared library with static components
-
I have two algorithms that i am developing into dlls. They use some common code and so I am building a static library that both dll can use. When I compile the algorithm I get a bunch of LNK2019: unresolved external symbol errors. Also get some LNK2001: unresolved external symbol errors as well.
My pro files are set up in such a way that they use pri files to allow certain settings.
the static shared or common pro file is:
@include(../options.pri)
TEMPLATE = lib
CONFIG += staticINCLUDEPATH += .
DEPENDPATH += $$INCLUDEPATHSOURCES +=
*.cpp files\HEADERS +=
*.h files...@My algorithm code pro files is :
@include(../options.pri)
QT -= gui
TARGET = StaticAlgorithm
TEMPLATE = lib
CONFIG += sharedinclude(../common/includeme.pri)
INCLUDEPATH += .
DEPENDPATH += $$INCLUDEPATH
DEFINES += STATICALGORITHM_LIBRARY
SOURCES += *.cpp files\
HEADERS += *.h files\
unix:!symbian {
maemo5 {
target.path = /opt/usr/lib
} else {
target.path = /usr/lib
}
INSTALLS += target
}@My 3 pri files are the following:
options.pri
@CONFIG -= debug
CONFIG += releaseCONFIG += silent
DEFINES += USING_QT
UI_DIR = .ui
MOC_DIR = .mocwin32 {
QMAKE_CXXFLAGS += /MP
QMAKE_CXXFLAGS += -D_SCL_SECURE_NO_WARNINGS
} else {
}
exists( $$PWD/options.user ) {
include( $$PWD/options.user )
}OBJECTS_DIR = .obj/release
debug { OBJECTS_DIR = .obj/debug }exists($$QMAKE_LIBDIR_QT/libQtGui.a) {
DEFINES += QT_STATIC_LIB
} else {
DEFINES += QT_SHARED_LIB
}
@includeme.pri
@LIB_NAME=common
LIB_DIR=$$PWDinclude($$PWD/../PriFiles/includeme.template.pri)@
template
@INCLUDEPATH += $$LIB_DIR
DEPENDPATH += $$LIB_DIRIf an app is including this file (versus another lib),
add the lib path for them:
contains(TEMPLATE, app) {
LIB_BUILD_DIR= win32 { LIB_BUILD_DIR=/release debug { LIB_BUILD_DIR=/debug } } QMAKE_LIBDIR += $$LIB_DIR$$LIB_BUILD_DIR win32 { PRE_TARGETDEPS += $$LIB_DIR$$LIB_BUILD_DIR/$${LIB_NAME}.lib LIBS += $$LIB_DIR$$LIB_BUILD_DIR/$${LIB_NAME}.lib } else { PRE_TARGETDEPS += $$LIB_DIR$$LIB_BUILD_DIR/lib$${LIB_NAME}.a LIBS += -l$${LIB_NAME} }
}@
When I build the algorithm as a static library it compiles fine, but as soon as I try to make it a shared library I get the errors.