When building QGIS source code with QT Creator in windows 10, there are some error LNK2001.
Solved
General and Desktop
-
What is the bug or the crash?
[2961/5289 3.3/sec] Automatic MOC for target test_core_layoutitem [2962/5289 3.3/sec] Automatic MOC for target test_core_layoutitemgroup [2963/5289 3.3/sec] Linking CXX shared library output\bin\qgis_gui.dll FAILED: output/bin/qgis_gui.dll src/gui/qgis_gui.lib C:\Windows\system32\cmd.exe /C "cd . && E:\CMake\bin\cmake.exe -E vs_link_dll --intdir=src\gui\CMakeFiles\qgis_gui.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- E:\MICROS~1\MICROS~2\VC\Tools\MSVC\1442~1.344\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\qgis_gui.rsp /out:output\bin\qgis_gui.dll /implib:src\gui\qgis_gui.lib /pdb:output\bin\qgis_gui.pdb /dll /version:3.39 /machine:x64 /debug /INCREMENTAL && cd ." LINK Pass 1: command "E:\MICROS~1\MICROS~2\VC\Tools\MSVC\1442~1.344\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\qgis_gui.rsp /out:output\bin\qgis_gui.dll /implib:src\gui\qgis_gui.lib /pdb:output\bin\qgis_gui.pdb /dll /version:3.39 /machine:x64 /debug /INCREMENTAL /MANIFEST /MANIFESTFILE:src\gui\CMakeFiles\qgis_gui.dir/intermediate.manifest src\gui\CMakeFiles\qgis_gui.dir/manifest.res" failed (exit code 1120) with the following output: 正在创建库 src\gui\qgis_gui.lib 和对象 src\gui\qgis_gui.exp qgstemporalcontrollerwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgstextformatwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsunitselectionwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsqueryresultwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsstyleitemslistwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgssubstitutionlistwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgstablewidgetbase.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsorderbydialog.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgspanelwidgetstack.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgspresetcolorrampdialog.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsproviderguiregistry.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsnewhttpconnection.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsnewmemorylayerdialog.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsnewvectorlayerdialog.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsnewgeopackagelayerdialog.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsfeatureselectiondlg.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsfielddomainwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsformlabelformatwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgshttpheaderwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsexpressionbuilderwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsexpressionlineedit.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsexpressionpreviewwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsexpressionselectiondialog.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgscompoundcolorwidget.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgscredentialdialog.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsdatasourceselectdialog.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsexpressionbuilderdialog.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ) qgsvectortilesourceselect.cpp.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QToolButton::checkStateSet(void)" (?checkStateSet@QToolButton@@MEAAXXZ)
Steps to reproduce the issue
- Open source code file cmake file.
- Build all projects under 'Release with Debug Information' mode.
Versions
3.39
Supported QGIS version
- I'm running a supported QGIS version according tothe roadmap.
New profile
- I tried with a newQGIS profile
Additional context
As for the build kit for QT creator:
- Compiler: Visual Studio Enterprise 2022 17.12.35527.113 (amd64)
- Debugger: Auto-detected CDB at C:Program Files (x86)\Windows Kits\10\Debuggers\x86\cdb.exe
- QT version: Qt 5.15.2 MSVC2019 64bit
-
@haowong said in When building QGIS source code with QT Creator in windows 10, there are some error LNK2001.:
protected: virtual void __cdecl QToolButton::checkStateSet(void)
It looks like you have a mixture of source code built against Qt 6 but trying to link against Qt 5 libraries.
In Qt 5.15 the protected QToolButton::checkStateSet() is inherited from QAbstractButton and there is no override in QToolButton. In Qt 6.x there is a QToolButton::checkStateSet() override in QToolButton.
-