Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. LINK errors for pure Visual Studio

LINK errors for pure Visual Studio

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.4k Views
  • 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.
  • S Offline
    S Offline
    sylvalas
    wrote on last edited by
    #1

    I'm new to C++ qt I want to transfer to C++ because there are things I cant do with python (not Qt wise). I have been struggling with this trouble for like half a year moving forward and back between c++ and python and this is really tiring.

    The errors are basically like:
    *error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QApplication::QApplication(int &,char * ,int)" (_imp??0QApplication@@QEAA@AEAHPEAPEADH@Z) referenced in function main
    *error LNK2001: unresolved external symbol "protected: virtual bool __cdecl QMenuBar::event(class QEvent )" (?event@QMenuBar@@MEAA_NPEAVQEvent@@@Z)

    I have read loads of similar threads about this but none has solved my problem yet.

    I'm using Qt6.2.2, 6.2.2_msvc2019_64 with Microsoft Visual Studio 2022, std::C++
    latest

    What I thought might be useful and tried are:

    project properties>linker>general>Additional Library Directories (I added the dir for all qt lib files)
    project properties>linker>Input>Additional Dependencies (I added the Qt6Multimedia.lib and Qt6MultimediaWidgets.lib)

    Here's my main code:

    #include<QtWidgets/QApplication>
    #include<ui_mainWin.h>
    
    
    
    
    int main(int argc, char* argv[])
    {
    	Ui_MainWindow ui; //from <ui_mainWin.h>
    	QApplication app(argc, argv);
    	QMainWindow  canvas;
    	QMainWindow* pCanvas;
    	pCanvas = &canvas;
    	ui.setupUi(pCanvas);
    	canvas.show();
    	return 0;
    }
    

    <ui_mainWin.h> is automatically generated by qt tools from the namesake ui file I guess. It didn't raise any error from that anyways.

    Many thanks,
    Christopher

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @sylvalas said in LINK errors for pure Visual Studio:

      project properties>linker>Input>Additional Dependencies (I added the Qt6Multimedia.lib and Qt6MultimediaWidgets.lib)

      But the missing symbols are not in Qt6Multimedia but in QtWidgets - so link also against the QtWidgets library. Or use a proper build system like cmake, qmake or the Qt Visual Studio plugin and let do this stuff for you.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • S Offline
        S Offline
        sylvalas
        wrote on last edited by
        #3

        Thank you very much!!!
        Tho the window is still not showing but I guess thats something else. The LNK errors are gone.
        By qt visual studio plugin do you mean Qt VS tool or is there anything else? And I am not really sure whats cmake and qmake. I saw many ppl ask them to get a .pro file. Emmm that just doesn't fit my minimalism.

        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