Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problems encountered when the project moved from Mingw to MSVC 2017
Forum Updated to NodeBB v4.3 + New Features

Problems encountered when the project moved from Mingw to MSVC 2017

Scheduled Pinned Locked Moved Solved General and Desktop
30 Posts 5 Posters 8.0k Views
  • 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.
  • K Offline
    K Offline
    kgsbt
    wrote on last edited by kgsbt
    #19

    @JonB thanks. I resolved this problem!
    I put #include <complex.h> in The first line of AcBoardWorkspace.h. And put #include “AcBoardWorkspace.h” on the first line of the file that needs it.And it works!

    JonBJ 1 Reply Last reply
    1
    • K kgsbt

      @JonB thanks. I resolved this problem!
      I put #include <complex.h> in The first line of AcBoardWorkspace.h. And put #include “AcBoardWorkspace.h” on the first line of the file that needs it.And it works!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #20

      @kgsbt
      You were not supposed to be able to find clog in your own code --- it's in complex.h. And you were not supposed to deploy the solution to prefix it with :: as that would be in that file which you do not want to change.

      I put #include <complex.h> in The first line of AcBoardWorkspace.h. And put #include “AcBoardWorkspace.h” on the first line of the file that needs it.And it works!

      This is right. Something you have now moved it before in your #include files will have using namespace std. That will have made clog (without the ::) go wrong when complex.h got included. Now complex.h will be included before that std statement, and will allow it to work.

      As a general guide: this does not always avoid any problems, but I arrange my #includes as far as possible:

      1. First any "system" includes, which have nothing to do with Qt.
      2. Next any third-party includes, which have nothing to do with Qt.
      3. Qt's includes.
      4. My own project's includes.

      In my experience this hopefully leads to the least interference between them.

      K 2 Replies Last reply
      1
      • JonBJ JonB

        @kgsbt
        You were not supposed to be able to find clog in your own code --- it's in complex.h. And you were not supposed to deploy the solution to prefix it with :: as that would be in that file which you do not want to change.

        I put #include <complex.h> in The first line of AcBoardWorkspace.h. And put #include “AcBoardWorkspace.h” on the first line of the file that needs it.And it works!

        This is right. Something you have now moved it before in your #include files will have using namespace std. That will have made clog (without the ::) go wrong when complex.h got included. Now complex.h will be included before that std statement, and will allow it to work.

        As a general guide: this does not always avoid any problems, but I arrange my #includes as far as possible:

        1. First any "system" includes, which have nothing to do with Qt.
        2. Next any third-party includes, which have nothing to do with Qt.
        3. Qt's includes.
        4. My own project's includes.

        In my experience this hopefully leads to the least interference between them.

        K Offline
        K Offline
        kgsbt
        wrote on last edited by
        #21

        @JonB said in Problems encountered when the project moved from Mingw to MSVC 2017:

        As a general guide: this does not always avoid any problems, but I arrange my #includes as far as possible:

        First any "system" includes, which have nothing to do with Qt.
        Next any third-party includes, which have nothing to do with Qt.
        Qt's includes.
        My own project's includes.

        This is a very useful guide!

        1 Reply Last reply
        0
        • JonBJ JonB

          @kgsbt
          You were not supposed to be able to find clog in your own code --- it's in complex.h. And you were not supposed to deploy the solution to prefix it with :: as that would be in that file which you do not want to change.

          I put #include <complex.h> in The first line of AcBoardWorkspace.h. And put #include “AcBoardWorkspace.h” on the first line of the file that needs it.And it works!

          This is right. Something you have now moved it before in your #include files will have using namespace std. That will have made clog (without the ::) go wrong when complex.h got included. Now complex.h will be included before that std statement, and will allow it to work.

          As a general guide: this does not always avoid any problems, but I arrange my #includes as far as possible:

          1. First any "system" includes, which have nothing to do with Qt.
          2. Next any third-party includes, which have nothing to do with Qt.
          3. Qt's includes.
          4. My own project's includes.

          In my experience this hopefully leads to the least interference between them.

          K Offline
          K Offline
          kgsbt
          wrote on last edited by
          #22

          @JonB I have a new problem:
          598ce18a1c9118d7bf2b10c81d73eb99.png
          I use QFutureWatcher<void> *watcher = new QFutureWatcher<void>(this); as usual.
          AcBoardEntity does inherit from QObject.But it get an error:

          • AcBoardEntity.cpp:423:41: error: no matching constructor for initialization of 'QFutureWatcher<void>'
            qfuturewatcher.h:184:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'AcBoardEntity *' to 'const QFutureWatcher<void>' for 1st argument
            qfuturewatcher.h:187:14: note: candidate constructor not viable: no known conversion from 'AcBoardEntity *' to 'QObject *' for 1st argument

          I also used QFutureWatcher<void> *watcher = new QFutureWatcher<void>(this); in another file:
          f3bc05a9e553af8002e92f19ed19905d.png
          and it works as usual.
          I don't kown what's wrong.

          JonBJ 1 Reply Last reply
          0
          • K kgsbt

            @JonB I have a new problem:
            598ce18a1c9118d7bf2b10c81d73eb99.png
            I use QFutureWatcher<void> *watcher = new QFutureWatcher<void>(this); as usual.
            AcBoardEntity does inherit from QObject.But it get an error:

            • AcBoardEntity.cpp:423:41: error: no matching constructor for initialization of 'QFutureWatcher<void>'
              qfuturewatcher.h:184:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'AcBoardEntity *' to 'const QFutureWatcher<void>' for 1st argument
              qfuturewatcher.h:187:14: note: candidate constructor not viable: no known conversion from 'AcBoardEntity *' to 'QObject *' for 1st argument

            I also used QFutureWatcher<void> *watcher = new QFutureWatcher<void>(this); in another file:
            f3bc05a9e553af8002e92f19ed19905d.png
            and it works as usual.
            I don't kown what's wrong.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #23

            @kgsbt
            I don't see where the difference is too. Start by deleting all your intermediate generated file and re-run a build from scratch, to make sure everything is correctly up-to-date (no artefacts left over from a previous compile).

            Yes, note something "odd" in your screenshot: class SignalGenerator has SignalGenerator written in bold & purple --- just like QObject is written in purple. But your class AcBoardEntity is not written that way. This implies to me it is not recognising something about the AcBoardEntity class which it is recognising for SignalGenerator....

            You show a "vertical red line warning symbol" at line #19 of AcBoardEntity.h. This may be affecting the interpretation of the subsequent class AcBoardEntity. What is that about, can that be resolved first?

            K 1 Reply Last reply
            0
            • JonBJ JonB

              @kgsbt
              I don't see where the difference is too. Start by deleting all your intermediate generated file and re-run a build from scratch, to make sure everything is correctly up-to-date (no artefacts left over from a previous compile).

              Yes, note something "odd" in your screenshot: class SignalGenerator has SignalGenerator written in bold & purple --- just like QObject is written in purple. But your class AcBoardEntity is not written that way. This implies to me it is not recognising something about the AcBoardEntity class which it is recognising for SignalGenerator....

              You show a "vertical red line warning symbol" at line #19 of AcBoardEntity.h. This may be affecting the interpretation of the subsequent class AcBoardEntity. What is that about, can that be resolved first?

              K Offline
              K Offline
              kgsbt
              wrote on last edited by
              #24

              @JonB said in Problems encountered when the project moved from Mingw to MSVC 2017:

              You show a "vertical red line warning symbol" at line #19 of AcBoardEntity.h

              it's just because I don't save the file.And red line tells me which changed.

              @JonB said in Problems encountered when the project moved from Mingw to MSVC 2017:

              Yes, note something "odd" in your screenshot: class SignalGenerator has SignalGenerator written in bold & purple --- just like QObject is written in purple. But your class AcBoardEntity is not written that way

              Yes! you're right.I note it.I looked up in Intertnet and found that:

              • "In Qt Creator, when you enter a class name, it should turn purple. This means that Qt Creator has recognized the class and that it is correctly included in the project.
                If you see that the class name is still black, this may mean that Qt Creator does not recognize the class or that the class is not properly included in the project. This problem usually results in compilation errors and other problems."

              I checked my code and found:
              db7cd2d15c88369989ea3d523b743ae8.png
              d882737010802f3b0314e4c2db04edd9.png
              the m_mq[8] is black,too. When I commented m_mq[8] out,class AcBoardEntity become bold & purple.
              I think there is a problem in m_mq[8] .
              here is the code about MessageQueue and MyMessage:

              //MessageQueue.h
              #ifndef MESSAGE_QUEUE_H
              #define MESSAGE_QUEUE_H
              
              #include <mutex>
              #include <condition_variable>
              #include <queue>
              
              template<class T> class MessageQueue {
              public:
              
                  void push(const T& msg) {
                      std::unique_lock<std::mutex>lck(m_mtx);
                      m_queue.push(msg);
                      m_cv.notify_one();
                  }
              
                  void wait(T& msg) {
                      std::unique_lock<std::mutex>lck(m_mtx);
                      while (!m_queue.size()) {
                          m_cv.wait(lck);
                      }
                      msg = m_queue.front();
                      m_queue.pop();
                  }
              
                  size_t size() {
                      std::unique_lock<std::mutex>lck(m_mtx);
                      return m_queue.size();
                  }
              private:
              
                  std::queue<T>               m_queue;
                  std::mutex                  m_mtx;
                  std::condition_variable     m_cv;
              };
              
              #endif // MESSAGE_QUEUE_H
              
              
              \\MyMessage
              class MyMessage {
              public:
                  uint8_t     id;
                  uint32_t    len;
                  unsigned char *buf;
              };
              

              can you find some problem?

              jsulmJ 1 Reply Last reply
              0
              • K kgsbt

                @JonB said in Problems encountered when the project moved from Mingw to MSVC 2017:

                You show a "vertical red line warning symbol" at line #19 of AcBoardEntity.h

                it's just because I don't save the file.And red line tells me which changed.

                @JonB said in Problems encountered when the project moved from Mingw to MSVC 2017:

                Yes, note something "odd" in your screenshot: class SignalGenerator has SignalGenerator written in bold & purple --- just like QObject is written in purple. But your class AcBoardEntity is not written that way

                Yes! you're right.I note it.I looked up in Intertnet and found that:

                • "In Qt Creator, when you enter a class name, it should turn purple. This means that Qt Creator has recognized the class and that it is correctly included in the project.
                  If you see that the class name is still black, this may mean that Qt Creator does not recognize the class or that the class is not properly included in the project. This problem usually results in compilation errors and other problems."

                I checked my code and found:
                db7cd2d15c88369989ea3d523b743ae8.png
                d882737010802f3b0314e4c2db04edd9.png
                the m_mq[8] is black,too. When I commented m_mq[8] out,class AcBoardEntity become bold & purple.
                I think there is a problem in m_mq[8] .
                here is the code about MessageQueue and MyMessage:

                //MessageQueue.h
                #ifndef MESSAGE_QUEUE_H
                #define MESSAGE_QUEUE_H
                
                #include <mutex>
                #include <condition_variable>
                #include <queue>
                
                template<class T> class MessageQueue {
                public:
                
                    void push(const T& msg) {
                        std::unique_lock<std::mutex>lck(m_mtx);
                        m_queue.push(msg);
                        m_cv.notify_one();
                    }
                
                    void wait(T& msg) {
                        std::unique_lock<std::mutex>lck(m_mtx);
                        while (!m_queue.size()) {
                            m_cv.wait(lck);
                        }
                        msg = m_queue.front();
                        m_queue.pop();
                    }
                
                    size_t size() {
                        std::unique_lock<std::mutex>lck(m_mtx);
                        return m_queue.size();
                    }
                private:
                
                    std::queue<T>               m_queue;
                    std::mutex                  m_mtx;
                    std::condition_variable     m_cv;
                };
                
                #endif // MESSAGE_QUEUE_H
                
                
                \\MyMessage
                class MyMessage {
                public:
                    uint8_t     id;
                    uint32_t    len;
                    unsigned char *buf;
                };
                

                can you find some problem?

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

                @kgsbt Are we talking about real build issues (when you build your project) or about warnings/errors QtCreator is shown in editor?

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

                JonBJ K 2 Replies Last reply
                0
                • jsulmJ jsulm

                  @kgsbt Are we talking about real build issues (when you build your project) or about warnings/errors QtCreator is shown in editor?

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #26

                  @jsulm
                  OP claims it's actual build error, he wrote earlier

                  AcBoardEntity does inherit from QObject.But it get an error:

                  AcBoardEntity.cpp:423:41: error: no matching constructor for initialization of 'QFutureWatcher<void>'

                  qfuturewatcher.h:184:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'AcBoardEntity *' to 'const QFutureWatcher<void>' for 1st argument

                  qfuturewatcher.h:187:14: note: candidate constructor not viable: no known conversion from 'AcBoardEntity *' to 'QObject *' for 1st argument

                  I think you only get those (and with line numbers) on real compilation?

                  1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @kgsbt Are we talking about real build issues (when you build your project) or about warnings/errors QtCreator is shown in editor?

                    K Offline
                    K Offline
                    kgsbt
                    wrote on last edited by kgsbt
                    #27

                    @jsulm @JonB I think it's warnings/errors QtCreator is shown in editor.
                    the error is showing when I open the AcBoardEntity.cpp and don't build the project:
                    1698971963307.jpg
                    *D:\QtProjects\autotest\1026msvc\autotestsystem\AutoTestSystem\AcBoard\AcBoardEntity.cpp:424: error: no matching constructor for initialization of 'QFutureWatcher<void>'
                    when I build,only get this error information in compile output:

                    ...
                    ...
                    cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DXLSX_NO_LIB -DQT_DEPRECATED_WARNINGS -D__MW_STDINT_H__ -DNDEBUG -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -I..\AutoTestSystem -I. -I..\AutoTestSystem -I..\AutoTestSystem\Tools -I..\AutoTestSystem\Tools -I..\AutoTestSystem\Log4Qt-master\src -I..\AutoTestSystem\Log4Qt-master\src\log4qt -I..\AutoTestSystem\Log4Qt-master\include -I..\AutoTestSystem\Log4Qt-master\include\log4qt -I..\AutoTestSystem\my_include -I..\AutoTestSystem\Common -I..\AutoTestSystem\Common -I..\AutoTestSystem\Common -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtGui\5.14.2 -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtGui\5.14.2\QtGui -ID:\Qt5.14.2\5.14.2\msvc2017_64\include -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtPrintSupport -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtWidgets -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtGui -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtANGLE -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtCore\5.14.2 -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtCore\5.14.2\QtCore -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtNetwork -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtConcurrent -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtCore -Irelease -I. -I/include -ID:\Qt5.14.2\5.14.2\msvc2017_64\mkspecs\win32-msvc -Forelease\AcBoardEntity.obj ..\AutoTestSystem\AcBoard\AcBoardEntity.cpp
                    AcBoardEntity.cpp
                    Internal compiler error in "D: Program Files (x86) Microsoft Visual Studio 2022 buildtools VC tools MSVC 14.16.27023 bin Hostx64 x64 cl.exe"
                    Please Select Visual C + + Support Command on the help menu, or open the support help file for details
                    ...
                    ...
                    jom: D:\QtProjects\autotest\1026msvc\autotestsystem\build-AutoTestSystem-Desktop_Qt_5_14_2_MSVC2017_64bit-Release\Makefile.Release [release\AcBoardEntity.obj] Error 2
                     jom: D:\QtProjects\autotest\1026msvc\autotestsystem\build-AutoTestSystem-Desktop_Qt_5_14_2_MSVC2017_64bit-Release\Makefile [release] Error 2
                     08:59:32: process“D: Qt5.14.2 tools qtcreator bin Jom.exe” exits, exit code 2.
                    Error while building/deploying project AutoTestSystem (kit: Desktop Qt 5.14.2 MSVC2017 64bit)
                    When executing step "Make"
                    
                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kgsbt
                      wrote on last edited by
                      #28

                      @JonB @jsulm Thanks for you help! I have solved the problem!

                      jsulmJ 1 Reply Last reply
                      0
                      • K kgsbt

                        @JonB @jsulm Thanks for you help! I have solved the problem!

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

                        @kgsbt Would be good to mention how you solved the problem

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

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          kgsbt
                          wrote on last edited by kgsbt
                          #30

                          @Jsulm I asked chatGPT for this question. It replied that :

                          • "If your Qt Creator can not resolve the Messagequeue < Mymessage > type correctly, try updating to the latest version of Qt Creator or try editing and compiling with another editor.Also, even if your editor can not parse the Messagequeue < Mymessage > type correctly, your code is still valid as long as the compiler compiles the code correctly. You can write, build, and test code without relying on the editor."

                          It means that the warnings/errors QtCreator is shown in editor. can be ignored.But without this problem, as I said before, it would not compile:

                          ...
                          ...
                          cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DXLSX_NO_LIB -DQT_DEPRECATED_WARNINGS -D__MW_STDINT_H__ -DNDEBUG -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -I..\AutoTestSystem -I. -I..\AutoTestSystem -I..\AutoTestSystem\Tools -I..\AutoTestSystem\Tools -I..\AutoTestSystem\Log4Qt-master\src -I..\AutoTestSystem\Log4Qt-master\src\log4qt -I..\AutoTestSystem\Log4Qt-master\include -I..\AutoTestSystem\Log4Qt-master\include\log4qt -I..\AutoTestSystem\my_include -I..\AutoTestSystem\Common -I..\AutoTestSystem\Common -I..\AutoTestSystem\Common -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtGui\5.14.2 -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtGui\5.14.2\QtGui -ID:\Qt5.14.2\5.14.2\msvc2017_64\include -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtPrintSupport -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtWidgets -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtGui -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtANGLE -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtCore\5.14.2 -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtCore\5.14.2\QtCore -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtNetwork -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtConcurrent -ID:\Qt5.14.2\5.14.2\msvc2017_64\include\QtCore -Irelease -I. -I/include -ID:\Qt5.14.2\5.14.2\msvc2017_64\mkspecs\win32-msvc -Forelease\AcBoardEntity.obj ..\AutoTestSystem\AcBoard\AcBoardEntity.cpp
                          AcBoardEntity.cpp
                          Internal compiler error in "D: Program Files (x86) Microsoft Visual Studio 2022 buildtools VC tools MSVC 14.16.27023 bin Hostx64 x64 cl.exe"
                          Please Select Visual C + + Support Command on the help menu, or open the support help file for details
                          ...
                          ...
                          jom: D:\QtProjects\autotest\1026msvc\autotestsystem\build-AutoTestSystem-Desktop_Qt_5_14_2_MSVC2017_64bit-Release\Makefile.Release [release\AcBoardEntity.obj] Error 2
                           jom: D:\QtProjects\autotest\1026msvc\autotestsystem\build-AutoTestSystem-Desktop_Qt_5_14_2_MSVC2017_64bit-Release\Makefile [release] Error 2
                           08:59:32: process“D: Qt5.14.2 tools qtcreator bin Jom.exe” exits, exit code 2.
                          Error while building/deploying project AutoTestSystem (kit: Desktop Qt 5.14.2 MSVC2017 64bit)
                          When executing step "Make"
                          

                          I guess there should be other issue.I recall, in ACBOARDENTITY. The most recent major change in the CPP file was: the error C1060 heap overrun due to the large array defined in the H file,so I replaced the array with a pointer and defined it in the CPP file.I thought maybe my pointer was written wrong, so I changed it back to the original array:

                          //.h
                          double m_sinForK[AC_BOARD_NUM*AC_PROBE_NUM][3840][125];
                          
                          //.cpp
                          memset(m_sinForK, 0, sizeof(m_sinForK));
                          

                          And it works!

                          1 Reply Last reply
                          0
                          • K kgsbt has marked this topic as solved on

                          • Login

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