Debugging in QtCreator using MSVC2017 compiler

I installed Qt, but I get errors when trying to debug C ++ code from QtCreator. I am using Visual Studio 2017 on Windows, and it looks like a debugger that QtCreator does not require (cdb.exe) is not installed. How to configure debugging to work with 64-bit code in QtCreator when using the MSVC2017 compiler?

(I answer my question according to https://stackoverflow.com/help/self-answer . Submit the best answer and I will change the accepted answer to yours!)

+4
source share
1 answer

What I'm discussing here is getting QtCreator working with Visual Studio 2017 compiler (MSVC2017), including debugging! By default, installing MSVC2017 and Qt 5.10 will allow you to compile and run the code, but by default you will not get debugging support. I will show the steps necessary for everything to be installed (including debugging support) for the following frame of reference:

reference system

  • Windows 7 SP1 x64 (works exactly the same with Win10, too)
  • Visual Studio 2017 (version 15.5.1)
  • Qt 5.10.0
  • Qt Creator 4.5.0 (MSVC 2015, 64-bit)
  • Windows Debugging Tools (CDB.exe) that DO NOT ship with Visual Studio 2017
    • via the Windows 10 SDK
  • Targeting 64-bit Windows Desktop Applications

Windows 10, Windows 7 (x64), , , . , QtCreator, Qt, 32- , , MSVC. , (. QtCreator Windows QtCreator Debugger Engines), , , , .

  • Windows 7 x64 Windows 10
  • Visual Studio 2017 ( 15.5.1)

, Win7/Win10 MSVC2017, !

Qt

  • qt-opensource-windows-x86-5.10.0.exe Qt
  • "msvc2017 64-bit".
    • .

Qt 5.10 Setup

Windows SDK Windows 10   - https://developer.microsoft.com/en-us/windows/downloads/sdk-archive

Windows 10 SDK

  • " Windows"

Windows 10 SDK Feature Selection

  • - " Windows".
  • ( x86 ):

    • Windows Kits\10\WindowsSDK\Installers\X64 -x64_en-us.msi
    • Windows Kits\10\WindowsSDK\Installers\X86 -x86_en-us.msi

Win SDK debugger installers

64- STAND-ALONE QtCreator

. QtCreator Windows, QtCreator , . QtCreator, , QtCreator .

  • "Qt Creator 4.5.0 Windows 64-bit"

enter image description here

  • " CDB" ( Qt Qt Creator)

Qt Creator 4.5.0 (64-bit) setup

QtCreator

QtCreator "Kit" + + Qt + . ( "Kit" , " Windows", , .) "QtCreator Kit", "" → → . , "". , (1,2,3) .

Order QtCreator Kit Configuration

QtCreator

  • C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe "Window Kit 10 cdb x64".

Debugger Tab in QtCreator

  • . , "Microsoft Visual ++ Compiler 15.0 (amd64)" . , QtCreator , . , .

  • , 64- Visual Studio 2017 "amd64", 64- . , , - "-". , , , , "x86_amd64" - 32- , 64- ; , 64- 32- ( -). , 64- , amd64. (- "x86_amd64" 64- .) QtCreator, , . ! . x64 "x86_amd64" "amd64" .

cpp-64-bit-compiler

Kit

  • .
  • . ; , .
  • . "Microsoft Visual ++ Compiler 15.0 (amd64)" C ++.
  • . "Windows Kit 10 cdb x64", "".
  • Qt - "Qt 5.10.0 (msvc2017_64). , Qt, .
  • .

Set up in Qt Creator

64- , . ( 32- Windows 2 , . 32- 64- ?). , , 32 , 64- . QtCreator, 64- Windows:

Debug 64-bit code in Qt Creator

, 64- MSVC2017 CDB.exe, .

#include <QCoreApplication>
#include <cassert>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    int intSize = sizeof(int);
    assert(intSize == 4);

    int intPtrSize = sizeof(int*);
    assert(intPtrSize == 8);

    constexpr size_t giga = 1000 * 1000 * 1000;

    size_t _32gigs = 32 * giga / intSize;
    int* gigaChunk = new int[_32gigs];
    assert(gigaChunk != nullptr);

    return a.exec();
}
+5

Source: https://habr.com/ru/post/1690612/


All Articles