Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. The C++ Compiler cannot run a simple test program
QtWS25 Last Chance

The C++ Compiler cannot run a simple test program

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
47 Posts 6 Posters 11.7k 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.
  • C cristian-adam
    18 May 2023, 14:08

    @Daemonitas This means that the compiler is fine. Then I guess it's a CMake problem! 🤯

    Qt delivers CMake 3.24.2 from Kitware, you can get a newer version from https://github.com/Kitware/CMake/tags

    Unpack https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-windows-x86_64.zip somewhere on your disk, and use this new path for the PATH environment variable and try again from command line.

    Same thing with cmake --version to make sure you have the right version.

    🤞

    D Offline
    D Offline
    Daemonitas
    wrote on 18 May 2023, 14:28 last edited by Daemonitas
    #23

    @cristian-adam
    So I do this right?
    c298d862-11f9-4609-9dee-a6642e07f74b-image.png

    And this is after I disabled windows defender

    f7b2b3f0-3b86-40cc-84a3-0728392df105-image.png

    C O 2 Replies Last reply 18 May 2023, 14:44
    0
    • D Daemonitas
      18 May 2023, 14:28

      @cristian-adam
      So I do this right?
      c298d862-11f9-4609-9dee-a6642e07f74b-image.png

      And this is after I disabled windows defender

      f7b2b3f0-3b86-40cc-84a3-0728392df105-image.png

      C Offline
      C Offline
      cristian-adam
      wrote on 18 May 2023, 14:44 last edited by
      #24

      Rename the build directory to build-ninja and then try with -G "MinGW Makefiles".

      How does it fail, similar with ABI checks?

      This is bad enough to have it reported upstream at CMake https://gitlab.kitware.com/groups/cmake/-/issues

      With the content of those error logs 😔

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cristian-adam
        wrote on 18 May 2023, 14:50 last edited by cristian-adam
        #25

        As an alternative, you could open a cmd.exe and this time trying it out with Visual C++.

        For this you need to to have Qt for MSVC installed at c:\Qt\6.5.0\msvc2019_64.

        Then:

        set PATH=C:/Qt/Tools/CMake_64/bin;C:/Qt/6.5.0/msvc2019_64/bin;%PATH%
        $ cmake -S . -B build -DCMAKE_PREFIX_PATH=C:/Qt/6.5.0/msvc2019_64 
        $ cmake --build build --config Release
        

        This time no -G was passed, CMake will pick up the Visual Studio generator using msbuild.

        If this works, then you'll have to change the Generator in Qt Creator's Kits configuration for the Visual C++ kit.

        Edit: new cmd.exe window, so that no MinGW bits are preset in the PATH variable, CMake should pick cl.exe as before when it complained about the missing QT package.

        D 1 Reply Last reply 18 May 2023, 14:58
        0
        • C cristian-adam
          18 May 2023, 14:50

          As an alternative, you could open a cmd.exe and this time trying it out with Visual C++.

          For this you need to to have Qt for MSVC installed at c:\Qt\6.5.0\msvc2019_64.

          Then:

          set PATH=C:/Qt/Tools/CMake_64/bin;C:/Qt/6.5.0/msvc2019_64/bin;%PATH%
          $ cmake -S . -B build -DCMAKE_PREFIX_PATH=C:/Qt/6.5.0/msvc2019_64 
          $ cmake --build build --config Release
          

          This time no -G was passed, CMake will pick up the Visual Studio generator using msbuild.

          If this works, then you'll have to change the Generator in Qt Creator's Kits configuration for the Visual C++ kit.

          Edit: new cmd.exe window, so that no MinGW bits are preset in the PATH variable, CMake should pick cl.exe as before when it complained about the missing QT package.

          D Offline
          D Offline
          Daemonitas
          wrote on 18 May 2023, 14:58 last edited by
          #26

          @cristian-adam
          about the Visual Studio thing I also tried using the Qt extension in Visual Studio but when I tried to create a new Qt Widget Application it shows this
          764904cd-6c35-4078-986e-67305c1d091d-image.png

          C 1 Reply Last reply 18 May 2023, 15:02
          0
          • D Daemonitas
            18 May 2023, 14:58

            @cristian-adam
            about the Visual Studio thing I also tried using the Qt extension in Visual Studio but when I tried to create a new Qt Widget Application it shows this
            764904cd-6c35-4078-986e-67305c1d091d-image.png

            C Offline
            C Offline
            cristian-adam
            wrote on 18 May 2023, 15:02 last edited by
            #27

            @Daemonitas Since I'm the maintainer of the CMake bits in Qt Creator I can't say much about the Visual Studio Qt plugin. A different colleague is responsible.

            Since the Visual Studio experiment from a few posts passed the ABI check, it means that at least that generator works.

            If you modify the generator to "Visual Studio" in the Qt 6.5.0 MSVC Kit like this:

            visual-studio-generator-cmake.png

            You should be able to to finally compile your application.

            D 1 Reply Last reply 18 May 2023, 15:09
            0
            • C cristian-adam
              18 May 2023, 15:02

              @Daemonitas Since I'm the maintainer of the CMake bits in Qt Creator I can't say much about the Visual Studio Qt plugin. A different colleague is responsible.

              Since the Visual Studio experiment from a few posts passed the ABI check, it means that at least that generator works.

              If you modify the generator to "Visual Studio" in the Qt 6.5.0 MSVC Kit like this:

              visual-studio-generator-cmake.png

              You should be able to to finally compile your application.

              D Offline
              D Offline
              Daemonitas
              wrote on 18 May 2023, 15:09 last edited by
              #28

              @cristian-adam
              Untitled2.png
              Here is the result in the "General Messages" tab

              C 1 Reply Last reply 18 May 2023, 15:25
              0
              • D Daemonitas
                18 May 2023, 15:09

                @cristian-adam
                Untitled2.png
                Here is the result in the "General Messages" tab

                C Offline
                C Offline
                cristian-adam
                wrote on 18 May 2023, 15:25 last edited by cristian-adam
                #29

                Since you have changed the generator in the Kit you would have to click in the Project settings on the "Re-configure with Initial Parameters" or just create a new project using this Kit.

                The new project will get the right generator and should configure just fine 🙂

                D 1 Reply Last reply 18 May 2023, 15:32
                0
                • C cristian-adam
                  18 May 2023, 15:25

                  Since you have changed the generator in the Kit you would have to click in the Project settings on the "Re-configure with Initial Parameters" or just create a new project using this Kit.

                  The new project will get the right generator and should configure just fine 🙂

                  D Offline
                  D Offline
                  Daemonitas
                  wrote on 18 May 2023, 15:32 last edited by Daemonitas
                  #30

                  @cristian-adam
                  it somehow worked (?) in a way
                  f5058f0c-77f5-44fd-9bce-eab0b48f580f-image.png
                  it enables the build and run button but at the same time it can't build when i'm using the minGw kit but when I use the MSVC kit it shows a ton of errors
                  Untitled3.png
                  as shown here

                  Edit:
                  cb692b09-50b7-4969-86af-20e8003298cd-image.png
                  this is the output on the MinGW kit

                  C 1 Reply Last reply 18 May 2023, 15:39
                  0
                  • D Daemonitas
                    18 May 2023, 15:32

                    @cristian-adam
                    it somehow worked (?) in a way
                    f5058f0c-77f5-44fd-9bce-eab0b48f580f-image.png
                    it enables the build and run button but at the same time it can't build when i'm using the minGw kit but when I use the MSVC kit it shows a ton of errors
                    Untitled3.png
                    as shown here

                    Edit:
                    cb692b09-50b7-4969-86af-20e8003298cd-image.png
                    this is the output on the MinGW kit

                    C Offline
                    C Offline
                    cristian-adam
                    wrote on 18 May 2023, 15:39 last edited by
                    #31

                    A MSVC Kit works with these generators:

                    • Ninja
                    • Visual Studio 17 2022
                    • NMake Makefiles
                    • NMake Makefiles - JOM

                    The MinGW Kit would work with these generators:

                    • Ninja
                    • MinGW Makefiles

                    You can't have a MinGW Kit working with a Visual Studio generator.

                    There is something broken on your PC. I'm running out of ideas.

                    D 1 Reply Last reply 18 May 2023, 15:47
                    0
                    • C cristian-adam
                      18 May 2023, 15:39

                      A MSVC Kit works with these generators:

                      • Ninja
                      • Visual Studio 17 2022
                      • NMake Makefiles
                      • NMake Makefiles - JOM

                      The MinGW Kit would work with these generators:

                      • Ninja
                      • MinGW Makefiles

                      You can't have a MinGW Kit working with a Visual Studio generator.

                      There is something broken on your PC. I'm running out of ideas.

                      D Offline
                      D Offline
                      Daemonitas
                      wrote on 18 May 2023, 15:47 last edited by Daemonitas
                      #32

                      @cristian-adam
                      for the msvc kit it seems the error to be in just one line
                      " <Exec Command="%(PreBuildEvent.Command)$(_BuildSuffix)" StdOutEncoding="%(PreBuildEvent.StdOutEncoding)" StdErrEncoding="%(PreBuildEvent.StdErrEncoding)" Condition="'%(PreBuildEvent.Command)' != ''"/>"

                      If nothing works Ig I cant use Qt then

                      Edit:
                      i tried changing the generator to MinGW Makefiles in the MinGw kit and get this error

                      fd933b38-0ede-4206-8e35-b749e6552b66-image.png

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        cristian-adam
                        wrote on 18 May 2023, 16:11 last edited by
                        #33

                        You should check your global PATH environment variable.

                        At https://github.com/isl-org/Open3D/issues/2316 it's being mentioned:

                        Error MSB3073 is generally caused by an incorrect path in the command line

                        You can type in Qt Creator in the Locator field (press Ctrl+K):

                        ! cmd /c set PATH
                        

                        In the General Messages pane you should get the output. Maybe you can paste it here.

                        This could explain why so many command line tools are broken.

                        C 1 Reply Last reply 18 May 2023, 16:12
                        0
                        • C cristian-adam
                          18 May 2023, 16:11

                          You should check your global PATH environment variable.

                          At https://github.com/isl-org/Open3D/issues/2316 it's being mentioned:

                          Error MSB3073 is generally caused by an incorrect path in the command line

                          You can type in Qt Creator in the Locator field (press Ctrl+K):

                          ! cmd /c set PATH
                          

                          In the General Messages pane you should get the output. Maybe you can paste it here.

                          This could explain why so many command line tools are broken.

                          C Offline
                          C Offline
                          cristian-adam
                          wrote on 18 May 2023, 16:12 last edited by
                          #34

                          On this Arm64 Laptop I have something like:

                          Starting command "cmd /c set PATH".
                          Path=C:\Projects\github\vcpkg;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Users\Cristian\AppData\Local\Programs\Python\Python311-arm64\Scripts\;C:\Users\Cristian\AppData\Local\Programs\Python\Python311-arm64\;C:\Users\Cristian\AppData\Local\Microsoft\WindowsApps;C:\Users\Cristian\AppData\Local\Microsoft\WinGet\Links;c:\Tools\cmake\bin;c:\Tools\ninja;c:\Tools\ccache;;C:\Users\Cristian\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Cristian\AppData\Local\Microsoft\WinGet\Packages\Microsoft.Sysinternals.ProcessExplorer_Microsoft.Winget.Source_8wekyb3d8bbwe;
                          PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
                          
                          The command "cmd /c set PATH" finished successfully.
                          

                          And for me all the things just work. Qt 6.5.0 with MSVC and MinGW.

                          D 1 Reply Last reply 18 May 2023, 16:14
                          0
                          • C cristian-adam
                            18 May 2023, 16:12

                            On this Arm64 Laptop I have something like:

                            Starting command "cmd /c set PATH".
                            Path=C:\Projects\github\vcpkg;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Users\Cristian\AppData\Local\Programs\Python\Python311-arm64\Scripts\;C:\Users\Cristian\AppData\Local\Programs\Python\Python311-arm64\;C:\Users\Cristian\AppData\Local\Microsoft\WindowsApps;C:\Users\Cristian\AppData\Local\Microsoft\WinGet\Links;c:\Tools\cmake\bin;c:\Tools\ninja;c:\Tools\ccache;;C:\Users\Cristian\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Cristian\AppData\Local\Microsoft\WinGet\Packages\Microsoft.Sysinternals.ProcessExplorer_Microsoft.Winget.Source_8wekyb3d8bbwe;
                            PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
                            
                            The command "cmd /c set PATH" finished successfully.
                            

                            And for me all the things just work. Qt 6.5.0 with MSVC and MinGW.

                            D Offline
                            D Offline
                            Daemonitas
                            wrote on 18 May 2023, 16:14 last edited by Daemonitas
                            #35

                            @cristian-adam
                            Path=C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Cloudflare\Cloudflare WARP;C:\Program Files\dotnet;C:\Program Files\Java\jdk-19\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Qt\Tools\QtCreator\bin;D:\MinGw\bin;C:\cmake-3.26.3-windows-x86_64\cmake-3.26.3-windows-x86_64\bin;C:\Users-redacted-\AppData\Local\Microsoft\WindowsApps;C:\Users-redacted-\Documents\MinGW\bin
                            PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

                            C 1 Reply Last reply 18 May 2023, 16:29
                            0
                            • D Daemonitas
                              18 May 2023, 16:14

                              @cristian-adam
                              Path=C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Cloudflare\Cloudflare WARP;C:\Program Files\dotnet;C:\Program Files\Java\jdk-19\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Qt\Tools\QtCreator\bin;D:\MinGw\bin;C:\cmake-3.26.3-windows-x86_64\cmake-3.26.3-windows-x86_64\bin;C:\Users-redacted-\AppData\Local\Microsoft\WindowsApps;C:\Users-redacted-\Documents\MinGW\bin
                              PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

                              C Offline
                              C Offline
                              cristian-adam
                              wrote on 18 May 2023, 16:29 last edited by
                              #36

                              @Daemonitas said in The C++ Compiler cannot run a simple test program:

                              @cristian-adam
                              Path=C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Cloudflare\Cloudflare WARP;C:\Program Files\dotnet;C:\Program Files\Java\jdk-19\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Qt\Tools\QtCreator\bin;D:\MinGw\bin;C:\cmake-3.26.3-windows-x86_64\cmake-3.26.3-windows-x86_64\bin;C:\Users-redacted-\AppData\Local\Microsoft\WindowsApps;C:\Users-redacted-\Documents\MinGW\bin
                              PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

                              I can't see anything that would break things 😔

                              How does the MSVC Kit with NMake Makefiles JOM generator work?

                              D 1 Reply Last reply 18 May 2023, 17:02
                              0
                              • C cristian-adam
                                18 May 2023, 16:29

                                @Daemonitas said in The C++ Compiler cannot run a simple test program:

                                @cristian-adam
                                Path=C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Cloudflare\Cloudflare WARP;C:\Program Files\dotnet;C:\Program Files\Java\jdk-19\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Qt\Tools\QtCreator\bin;D:\MinGw\bin;C:\cmake-3.26.3-windows-x86_64\cmake-3.26.3-windows-x86_64\bin;C:\Users-redacted-\AppData\Local\Microsoft\WindowsApps;C:\Users-redacted-\Documents\MinGW\bin
                                PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

                                I can't see anything that would break things 😔

                                How does the MSVC Kit with NMake Makefiles JOM generator work?

                                D Offline
                                D Offline
                                Daemonitas
                                wrote on 18 May 2023, 17:02 last edited by Daemonitas
                                #37

                                @cristian-adam
                                the build button was disabled again

                                oops I accidentally marked it as solved

                                D 1 Reply Last reply 19 May 2023, 01:27
                                0
                                • D Daemonitas has marked this topic as solved on 18 May 2023, 17:16
                                • D Daemonitas has marked this topic as unsolved on 18 May 2023, 17:16
                                • G Offline
                                  G Offline
                                  goldenhawking
                                  wrote on 18 May 2023, 22:55 last edited by
                                  #38

                                  QMake sometimes is simpler than CMake for simple applications.

                                  Qt is the best C++ framework I've ever met.

                                  1 Reply Last reply
                                  0
                                  • D Daemonitas
                                    18 May 2023, 17:02

                                    @cristian-adam
                                    the build button was disabled again

                                    oops I accidentally marked it as solved

                                    D Offline
                                    D Offline
                                    Daemonitas
                                    wrote on 19 May 2023, 01:27 last edited by
                                    #39

                                    @Daemonitas
                                    f65d87ee-ebe6-4859-955f-fde729cdbbee-image.png
                                    I got this pop up now when compiling using the msvc kit

                                    1 Reply Last reply
                                    0
                                    • D Daemonitas
                                      18 May 2023, 14:28

                                      @cristian-adam
                                      So I do this right?
                                      c298d862-11f9-4609-9dee-a6642e07f74b-image.png

                                      And this is after I disabled windows defender

                                      f7b2b3f0-3b86-40cc-84a3-0728392df105-image.png

                                      O Offline
                                      O Offline
                                      Orkun Tokdemir
                                      wrote on 19 May 2023, 08:17 last edited by
                                      #40

                                      @Daemonitas Can you compile anything with the compiler CMake found?
                                      Can you please try it with the hello word code?

                                      <the full path I highlighted>  hello.cpp -o hello 
                                      

                                      bc080015-b7a0-4432-8150-6c2de00f10c5-image.png

                                      D 1 Reply Last reply 19 May 2023, 08:32
                                      0
                                      • O Orkun Tokdemir
                                        19 May 2023, 08:17

                                        @Daemonitas Can you compile anything with the compiler CMake found?
                                        Can you please try it with the hello word code?

                                        <the full path I highlighted>  hello.cpp -o hello 
                                        

                                        bc080015-b7a0-4432-8150-6c2de00f10c5-image.png

                                        D Offline
                                        D Offline
                                        Daemonitas
                                        wrote on 19 May 2023, 08:32 last edited by
                                        #41

                                        @Orkun-Tokdemir
                                        you mean this one?
                                        23ca8fb9-2b0f-4597-8f17-3ff3738949c9-image.png

                                        O 1 Reply Last reply 19 May 2023, 08:45
                                        0
                                        • D Daemonitas
                                          19 May 2023, 08:32

                                          @Orkun-Tokdemir
                                          you mean this one?
                                          23ca8fb9-2b0f-4597-8f17-3ff3738949c9-image.png

                                          O Offline
                                          O Offline
                                          Orkun Tokdemir
                                          wrote on 19 May 2023, 08:45 last edited by
                                          #42

                                          @Daemonitas yes

                                          D 1 Reply Last reply 19 May 2023, 08:50
                                          0

                                          32/47

                                          18 May 2023, 15:47

                                          • Login

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