# cmake-gui linker errors

**URL:** https://discourse.cmake.org/t/cmake-gui-linker-errors/13470
**Category:** Usage
**Tags:** os:windows
**Created:** [January 23, 2025, 11:31pm UTC](https://discourse.cmake.org/t/cmake-gui-linker-errors/13470 "2025-01-23T23:31:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ralian](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ralian/32/5309_2.png) [@ralian](https://discourse.cmake.org/u/ralian)
#### Post date: [January 23, 2025, 11:31pm UTC](https://discourse.cmake.org/t/cmake-gui-linker-errors/13470/1 "2025-01-23T23:31:22Z")

</div>

Hello, I am trying to build the Qt-based cmake-gui as I want to get started developing for it. I am working on Windows with Visual Studio 17 2022 as my generator and compiler, and I am able to build the base CMake executable just fine.

I have a fresh Qt installed via chocolatey, version 5.15.2. I have `Qt5_Dir` set to `C:/Qt/5.15.2/mingw81_64/lib/cmake/Qt5` as well as `Qt5Widgets_Dir`, `Qt5Core_Dir`, `Qt5Gui_Dir`, and even `Qt5WinExtras_Dir` set to their appropriate locations. I do not have Qt6 installed, and I even set the variable to force `CMake_QT_MAJOR_VERSION` to `5` instead of `A`.

The `cmake-gui` sources compile perfectly fine, but they fail to link. There are only 6 linker errors, which leads me to believe the executable is at least partially linking. Here is the relevant output from calling `cmake --build .`:

```auto
...
  cmake.vcxproj -> C:\Users\wbowe\CMake\build\bin\Debug\cmake.exe
CMakeGUIExec.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int__cdecl QApplica
tion::exec(void)" (__imp_?exec@QApplication@@SAHXZ) referenced in function "int__cdecl CMakeGUIExec(class CMakeSetupDi
alog *)" (?CMakeGUIExec@@YAHPEAVCMakeSetupDialog@@@Z) [C:\Users\wbowe\CMake\build\Source\QtDialog\cmake-gui.vcxproj]
qrc_CMakeSetup.obj : error LNK2019: unresolved external symbol "bool __cdecl qRegisterResourceData(int,unsigned char co
nst *,unsigned char const *,unsigned char const *)" (?qRegisterResourceData@@YA_NHPEBE00@Z) referenced in function "int
 __cdecl qInitResources_CMakeSetup(void)" (?qInitResources_CMakeSetup@@YAHXZ) [C:\Users\wbowe\CMake\build\Source\QtDial
og\cmake-gui.vcxproj]
qrc_CMakeSetup.obj : error LNK2019: unresolved external symbol "bool __cdecl qUnregisterResourceData(int,unsigned char
const *,unsigned char const *,unsigned char const *)" (?qUnregisterResourceData@@YA_NHPEBE00@Z) referenced in function
"int __cdecl qCleanupResources_CMakeSetup(void)" (?qCleanupResources_CMakeSetup@@YAHXZ) [C:\Users\wbowe\CMake\build\Sou
rce\QtDialog\cmake-gui.vcxproj]
libqtmain.a(qtmain_win.o) : error LNK2019: unresolved external symbol _Znay referenced in function WinMain [C:\Users\wb
owe\CMake\build\Source\QtDialog\cmake-gui.vcxproj]
libqtmain.a(qtmain_win.o) : error LNK2019: unresolved external symbol _Z5qMainiPPc referenced in function WinMain [C:\U
sers\wbowe\CMake\build\Source\QtDialog\cmake-gui.vcxproj]
libqtmain.a(qtmain_win.o) : error LNK2019: unresolved external symbol _ZdaPv referenced in function WinMain [C:\Users\w
bowe\CMake\build\Source\QtDialog\cmake-gui.vcxproj]
C:\Users\wbowe\CMake\build\bin\Debug\cmake-gui.exe : fatal error LNK1120: 6 unresolved externals [C:\Users\wbowe\CMake\
build\Source\QtDialog\cmake-gui.vcxproj]
  cmcldeps.vcxproj -> C:\Users\wbowe\CMake\build\bin\Debug\cmcldeps.exe
  cmsys_c.vcxproj -> C:\Users\wbowe\CMake\build\Source\kwsys\Debug\cmsys_c.lib
...

```

Has anyone seen this before - or better yet, is there a tutorial I could follow on building this for Windows? I didn’t see instructions anywhere in the git repo.

---

<div class="post-metadata">

### Author: ![bill.hoffman](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bill.hoffman/32/13_2.png) [@bill.hoffman](https://discourse.cmake.org/u/bill.hoffman)
#### Post date: [January 24, 2025, 7:32pm UTC](https://discourse.cmake.org/t/cmake-gui-linker-errors/13470/2 "2025-01-24T19:32:24Z")

</div>

> [@ralian](#):
>
> `qtmain_win.o`

That looks wrong. I think you have to use an MSVC built QT. That looks like mingw built one. MSVC has .obj files not .o files.

---

<div class="post-metadata">

### Author: ![ralian](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ralian/32/5309_2.png) [@ralian](https://discourse.cmake.org/u/ralian)
#### Post date: [January 24, 2025, 8:57pm UTC](https://discourse.cmake.org/t/cmake-gui-linker-errors/13470/3 "2025-01-24T20:57:31Z")

</div>

Ah, it didn’t occur to me that the package from the chocolatey repo would be MinGW based, but it’s right there in the folder name. Thanks, I’ll retry it with MSVC QT and get back to you.

---

<div class="post-metadata">

### Author: ![ralian](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ralian/32/5309_2.png) [@ralian](https://discourse.cmake.org/u/ralian)
#### Post date: [January 24, 2025, 10:28pm UTC](https://discourse.cmake.org/t/cmake-gui-linker-errors/13470/4 "2025-01-24T22:28:09Z")

</div>

That worked. Thanks again. For reference, I just had to use aqi to install the correct package:

```auto
aqt install-qt windows desktop 5.15.2 win64_msvc2019_64

```
