Open tanggengsheng opened 6 months ago
I had installed Qt6 with llvm-mingw 64-bit kit on Windows 11. And I create a Qt project on VSCode, It compiled succeed but failed to link.
[main] Building folder: FramelessWindow [build] Starting build [proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --build c:/Users/tgs/Documents/Qt/FramelessWindow/build --config Debug --target all -j 8 -- [build] [ 0%] Built target FramelessWindow_autogen_timestamp_deps [build] [ 16%] Built target FramelessWindow_autogen [build] [ 33%] Linking CXX executable FramelessWindow.exe [build] ld.lld: error: undefined symbol: __declspec(dllimport) QObjectData::dynamicMetaObject() const [build] >>> referenced by C:\Users\tgs\Documents\Qt\FramelessWindow\build\FramelessWindow_autogen/UVLADIE3JM/moc_FramelessWindow.cpp:78 [build] >>> objects.a(mocs_compilation.cpp.obj):(FramelessWindow::metaObject() const) [build] [build] ld.lld: error: undefined symbol: __declspec(dllimport) QMainWindow::qt_metacast(char const*) [build] >>> referenced by C:\Users\tgs\Documents\Qt\FramelessWindow\build\FramelessWindow_autogen/UVLADIE3JM/moc_FramelessWindow.cpp:86 [build] >>> objects.a(mocs_compilation.cpp.obj):(FramelessWindow::qt_metacast(char const*)) [build] [build] ld.lld: error: undefined symbol: __declspec(dllimport) QMainWindow::qt_metacall(QMetaObject::Call, int, void**) [build] >>> referenced by C:\Users\tgs\Documents\Qt\FramelessWindow\build\FramelessWindow_autogen/UVLADIE3JM/moc_FramelessWindow.cpp:91 [build] >>> objects.a(mocs_compilation.cpp.obj):(FramelessWindow::qt_metacall(QMetaObject::Call, int, void**)) [build] [build] ld.lld: error: undefined symbol: __declspec(dllimport) QMainWindow::staticMetaObject [build] >>> referenced by C:/Users/tgs/anaconda3/Library/include/qt/QtCore/qobjectdefs.h:577 [build] >>> objects.a(mocs_compilation.cpp.obj):(QMetaObject const* QMetaObject::staticMetaObject<QMainWindow::staticMetaObject>()) [build] [build] ld.lld: error: undefined symbol: QMainWindow::event(QEvent*) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QObject::eventFilter(QObject*, QEvent*) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QObject::timerEvent(QTimerEvent*) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QObject::childEvent(QChildEvent*) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QObject::customEvent(QEvent*) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QObject::connectNotify(QMetaMethod const&) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QObject::disconnectNotify(QMetaMethod const&) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QWidget::devType() const [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QWidget::setVisible(bool) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QWidget::sizeHint() const [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QWidget::minimumSizeHint() const [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QWidget::heightForWidth(int) const [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QWidget::hasHeightForWidth() const [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QWidget::paintEngine() const [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QWidget::mousePressEvent(QMouseEvent*) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: undefined symbol: QWidget::mouseReleaseEvent(QMouseEvent*) [build] >>> referenced by objects.a(mocs_compilation.cpp.obj):(vtable for FramelessWindow) [build] [build] ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors) [build] clang-17: error: linker command failed with exit code 1 (use -v to see invocation) [build] mingw32-make[2]: *** [CMakeFiles\FramelessWindow.dir\build.make:144: FramelessWindow.exe] Error 1 [build] mingw32-make[1]: *** [CMakeFiles\Makefile2:85: CMakeFiles/FramelessWindow.dir/all] Error 2 [build] mingw32-make: *** [Makefile:90: all] Error 2 [proc] The command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --build c:/Users/tgs/Documents/Qt/FramelessWindow/build --config Debug --target all -j 8 -- exited with code: 2 [driver] Build completed: 00:00:00.811 [build] Build finished with exit code 2
Why it use Visual Studio to build the project? I had choose the llvm kit.
I had installed Qt6 with llvm-mingw 64-bit kit on Windows 11. And I create a Qt project on VSCode, It compiled succeed but failed to link.
Why it use Visual Studio to build the project? I had choose the llvm kit.