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. Linking QT Application to Visual Studio Static 32 bit library fails
Forum Updated to NodeBB v4.3 + New Features

Linking QT Application to Visual Studio Static 32 bit library fails

Scheduled Pinned Locked Moved Installation and Deployment
2 Posts 2 Posters 1.3k 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.
  • J Offline
    J Offline
    johnco3
    wrote on last edited by
    #1

    (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 = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    INCLUDEPATH += /main/ltib/cpas/include
    /main/ltib/extlibs/pthreads-w32-2-8-0/include
    /main/ltib/extlibs/GnuWin32/include
    /main/ltib/sipXportLib/include

    win32: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/ -lloadset

    INCLUDEPATH += $$PWD/../../ltib/cpas/win32/loadset/Debug
    DEPENDPATH += $$PWD/../../ltib/cpas/win32/loadset/Debug

    win32: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();
    }
    @

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

      Hi,

      You can re-use it for another problem (hope you won't need to though) :)

      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

      • Login

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