Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. MSVC debug build doesn't work
Forum Updated to NodeBB v4.3 + New Features

MSVC debug build doesn't work

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
9 Posts 4 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sylhat
    wrote on last edited by Sylhat
    #1

    I built Qt following instructions from here using MSVS Community 2017 and the newest version of Qt from git repository. My configure command was "configure -prefix “f:\Programs\Qt\Qt5.9_MSVC” -developer-build -opensource -confirm-license -nomake examples -nomake tests -opengl desktop -debug-and-release -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -sql-sqlite -sql-odbc -make libs".
    Now I have a little test project (Qt Widgets Application) which works in a release build but have a “debug assertion failed” error in a debug build:
    File: minkernel\crts\ucrt\appcrt\heap\debug_heap.cpp
    Line: 904
    Expression: CrtlsValidHeapPointer(block)
    Also there is a compiler warning:
    “cl.exe” is used by qmake, but “” is configured in the kit.
    Please update your kit or choose a mkspec for qmake that matches your target environment better.
    These problems don't arise with a kit using MinGW compiler. What is wrong?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Looks like a bug or undefined behavior in your test project. The fact it works in release mode doesn't mean it really works. Maybe it just silently overwrites some memory but it doesn't have immediate effects that you can see.
      Anyway - it's hard to say without looking at the code or at least a call stack. Post it if you can.

      By the way - if you're not gonna modify Qt itself don't use -developer-build. It's bigger, slower and you don't need it for normal development of your apps. It also installs automatically in the build directory so the -prefix option you used is incompatible with it. Maybe that's what triggers the warning. Or your kit is just misconfigured - again hard to say without seeing. Post a screenshot of your kit properties page if you can.

      1 Reply Last reply
      4
      • S Offline
        S Offline
        Sylhat
        wrote on last edited by
        #3

        The code is simple:

        //mainwindow.cpp
        #include "mainwindow.h"
        #include "ui_mainwindow.h"
        #include <QPushButton>
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        
            connect(ui->pushButton, &QPushButton::clicked,
                    ui->label,
                    [this]()
            {
                ui->label->setText("Hello, World!");
            });
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
        

        The form was built in "design" mode. All other code is automatically generated.

        Thank you for your note about -developer-build. I'll try to configure building without this option

        jsulmJ 1 Reply Last reply
        0
        • S Sylhat

          The code is simple:

          //mainwindow.cpp
          #include "mainwindow.h"
          #include "ui_mainwindow.h"
          #include <QPushButton>
          
          MainWindow::MainWindow(QWidget *parent) :
              QMainWindow(parent),
              ui(new Ui::MainWindow)
          {
              ui->setupUi(this);
          
              connect(ui->pushButton, &QPushButton::clicked,
                      ui->label,
                      [this]()
              {
                  ui->label->setText("Hello, World!");
              });
          }
          
          MainWindow::~MainWindow()
          {
              delete ui;
          }
          

          The form was built in "design" mode. All other code is automatically generated.

          Thank you for your note about -developer-build. I'll try to configure building without this option

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Sylhat said in MSVC debug build doesn't work:

           connect(ui->pushButton, &QPushButton::clicked,
                       ui->label,
                       [this]()
               {
                   ui->label->setText("Hello, World!");
               });
          

          Why do you have ui->label in connect() if you use a lambda?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          1
          • jsulmJ jsulm

            @Sylhat said in MSVC debug build doesn't work:

             connect(ui->pushButton, &QPushButton::clicked,
                         ui->label,
                         [this]()
                 {
                     ui->label->setText("Hello, World!");
                 });
            

            Why do you have ui->label in connect() if you use a lambda?

            S Offline
            S Offline
            Sylhat
            wrote on last edited by
            #5

            @jsulm said in MSVC debug build doesn't work:

            Why do you have ui->label in connect() if you use a lambda?

            Yes, it's redundant, thank you.

            J.HilkJ 1 Reply Last reply
            0
            • S Sylhat

              @jsulm said in MSVC debug build doesn't work:

              Why do you have ui->label in connect() if you use a lambda?

              Yes, it's redundant, thank you.

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @Sylhat said in MSVC debug build doesn't work:

              @jsulm said in MSVC debug build doesn't work:

              Why do you have ui->label in connect() if you use a lambda?

              Yes, it's redundant, thank you.

              No it's not,
              it connects the lambda to the existence of the label. If you delete your label, than the connect gets undon.

              Without it, you get a segfault crash, when you press the QPushButton, when the label does not exist.


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              3
              • S Offline
                S Offline
                Sylhat
                wrote on last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Sylhat
                  wrote on last edited by
                  #8

                  I've built it without -developer-build option and now it works! Thank you, Chris Kawa!

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Sylhat
                    wrote on last edited by
                    #9

                    This problem showed up again when I built static version (doing all the same but adding -static option to configure). Maybe something is still wrong with the dynamic build too. Here is a screenshot of the configuration of the kit:

                    Kit

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved