Linking QT Application to Visual Studio Static 32 bit library fails
-
(sorry I accidentally posted this question 2 times and I do not know how do delete this duplicate)
Hello All,
I am trying to get up to speed with adding a new GUI front end to a previously console based application. The existing application was developed in Visual Studio 2012 Professional. The existing console application (executable) comprises a main() and about 20 or so static 32 bit libraries.
I used the QT Creator (qt-windows-opensource-5.1.1-msvc2012_opengl-x86_64-offline & qt-vs-addin-1.2.2-opensource) to create a dummy application (using the built in QT Gui Application wizard) and then I choose the add library context popup to add one of these static libraries to the linker.
Next I added a single line of code to use the generated main.cpp to bring in a reference from the static library and after qmaking and building the project, it complained as follows:
@main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl LoadsetList::LoadsetList(void)" (??0LoadsetList@@QEAA@XZ) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "public: virtual __cdecl LoadsetList::~LoadsetList(void)" (??1LoadsetList@@UEAA@XZ) referenced in function main
debug\vcbuild.exe:-1: error: LNK1120: 2 unresolved externals@Can anyone shed any light on what might be going wrong.
Here is the project file (note that the include paths are setup to point to my existing source code for the static libraries and QT seems to recognize the code by auto-completion.
@#-------------------------------------------------Project created by QtCreator 2013-10-29T17:27:49
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = vcbuild
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
INCLUDEPATH += /main/ltib/cpas/include
/main/ltib/extlibs/pthreads-w32-2-8-0/include
/main/ltib/extlibs/GnuWin32/include
/main/ltib/sipXportLib/includewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../ltib/cpas/win32/loadset/release/ -lloadset
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../ltib/cpas/win32/loadset/debug/ -lloadsetINCLUDEPATH += $$PWD/../../ltib/cpas/win32/loadset/Debug
DEPENDPATH += $$PWD/../../ltib/cpas/win32/loadset/Debugwin32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../ltib/cpas/win32/loadset/release/loadset.lib
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../ltib/cpas/win32/loadset/debug/loadset.lib
@Here is the modified main.cpp: Note I simply put a single line referring to the LoadsetList object which resides in my static library
@#include <QApplication>
#include "mainwindow.h"
#include "loadset/LoadsetList.h"int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
LoadsetList loadsetList;
return a.exec();
}
@ -
Hi,
You can re-use it for another problem (hope you won't need to though) :)