LINK errors for pure Visual Studio
-
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++
latestWhat 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 -
@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.
-
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.