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

The C++ Compiler cannot run a simple test program

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
47 Posts 6 Posters 11.8k 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, 10:31

    CMakeLists.txtis the project file for your CMake project.

    You tried to configure the untitled6 in the wrong directory, your home directory C:\Users\-redacted-.

    Make sure you go to the project:

    $ d: 
    $ cd "D:/programm/C++ Homework Sem 2/untitled6"
    $ dir 
    $ cmake -S . -B build -DCMAKE_PREFIX_PATH=C:/Qt/6.5.0/mingw_64  -DCMAKE_BUILD_TYPE=Release
    

    cmake -S . means that CMake should look in the current directory for the CMakeLists.txt.

    I assume that you have the untitled6 CMake Qt project at D:/programm/C++ Homework Sem 2/untitled6, but you can use any other project.

    Regarding moc --version, where do you have Qt 6.5.0 for MinGW installed? It should be under C:/Qt/6.5.0/mingw_64/bin

    The whole exercise here is to get extra information by doing things manually, step by step.

    D Offline
    D Offline
    Daemonitas
    wrote on 18 May 2023, 11:07 last edited by
    #13

    @cristian-adam
    alright now it shows
    75bd019f-44dd-424f-a396-e2514ecd5150-image.png
    looks like I'm missing some packages (?)

    G C 2 Replies Last reply 18 May 2023, 12:04
    0
    • D Daemonitas
      18 May 2023, 11:07

      @cristian-adam
      alright now it shows
      75bd019f-44dd-424f-a396-e2514ecd5150-image.png
      looks like I'm missing some packages (?)

      G Offline
      G Offline
      goldenhawking
      wrote on 18 May 2023, 12:04 last edited by
      #14

      @Daemonitas Have you installed MSVC compiler together with MINGW? This picture shows that cmake try to config a MINGW Qt with MSVC 19.35.

      Try to remove MSVC options from PATH, or run full-path CMAKE from Qt directory.

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

      1 Reply Last reply
      0
      • D Daemonitas
        18 May 2023, 11:07

        @cristian-adam
        alright now it shows
        75bd019f-44dd-424f-a396-e2514ecd5150-image.png
        looks like I'm missing some packages (?)

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

        @Daemonitas you got the part with the project directory but skipped the other steps that I've provided:

        $ set PATH=C:/Qt/Tools/CMake_64/bin;C:/Qt/Tools/mingw1120_64/bin;C:/Qt/Tools/Ninja;C:/Qt/6.5.0/mingw_64/bin;%PATH%
        $ cmake --version
        $ ninja --version
        $ gcc --version
        $ moc --version
        

        Here I'm adding CMake, MinGW GCC, Ninja and Qt 6.5.0 build for MinGW to the PATH environment variable.

        Then I call the executables to make sure that they are available.

        All of them should be available and provide the expected version numbers.

        If you don't have moc then the path to your Qt MinGW installation is not correct, and you would need to adjust it.

        When this is OK, then you can go to the project directory and issue the CMake command and build the project.

        Edit: Oh, right. The CMake command had one important part missing, the Generator. Sorry about that:

        $ cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH=C:/Qt/6.5.0/mingw_64  -DCMAKE_BUILD_TYPE=Release
        

        By default CMake would pick the Visual Studio generator and that one ignores any MinGW compiler paths 🙂

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

          @Daemonitas you got the part with the project directory but skipped the other steps that I've provided:

          $ set PATH=C:/Qt/Tools/CMake_64/bin;C:/Qt/Tools/mingw1120_64/bin;C:/Qt/Tools/Ninja;C:/Qt/6.5.0/mingw_64/bin;%PATH%
          $ cmake --version
          $ ninja --version
          $ gcc --version
          $ moc --version
          

          Here I'm adding CMake, MinGW GCC, Ninja and Qt 6.5.0 build for MinGW to the PATH environment variable.

          Then I call the executables to make sure that they are available.

          All of them should be available and provide the expected version numbers.

          If you don't have moc then the path to your Qt MinGW installation is not correct, and you would need to adjust it.

          When this is OK, then you can go to the project directory and issue the CMake command and build the project.

          Edit: Oh, right. The CMake command had one important part missing, the Generator. Sorry about that:

          $ cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH=C:/Qt/6.5.0/mingw_64  -DCMAKE_BUILD_TYPE=Release
          

          By default CMake would pick the Visual Studio generator and that one ignores any MinGW compiler paths 🙂

          D Offline
          D Offline
          Daemonitas
          wrote on 18 May 2023, 12:57 last edited by Daemonitas
          #16

          @cristian-adam
          ccfe27d3-427a-43fa-9659-a92f5070b16f-image.png

          Here is the entire thing
          (I downloaded Qt Version 6.4.3)
          Beforehand I downloaded Version 6.5.0 but I thought downgrading would do something

          C 1 Reply Last reply 18 May 2023, 13:25
          0
          • D Daemonitas
            18 May 2023, 12:57

            @cristian-adam
            ccfe27d3-427a-43fa-9659-a92f5070b16f-image.png

            Here is the entire thing
            (I downloaded Qt Version 6.4.3)
            Beforehand I downloaded Version 6.5.0 but I thought downgrading would do something

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

            @Daemonitas This should have worked! The tools are present, can be started, have the right versions.

            What happens if you disable the real-time checking of Windows Defender?

            You could try with -G "MinGW Makefiles" instead of -G Ninja as CMake generator. But this should fail in a similar way.

            I assume the installation of MinGW was not corrupted, or that the system has disk failures. Something prevents the compiler to work properly.

            What happens if you try it out with a hello.cpp ?

            #include <iostream>
            
            int main() 
            {
               std::cout << "Hello C++ World\n";
            }
            

            with:

            $ g++ hello.cpp -o hello
            $ hello
            

            If this works then the compiler is fine.

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

              @Daemonitas This should have worked! The tools are present, can be started, have the right versions.

              What happens if you disable the real-time checking of Windows Defender?

              You could try with -G "MinGW Makefiles" instead of -G Ninja as CMake generator. But this should fail in a similar way.

              I assume the installation of MinGW was not corrupted, or that the system has disk failures. Something prevents the compiler to work properly.

              What happens if you try it out with a hello.cpp ?

              #include <iostream>
              
              int main() 
              {
                 std::cout << "Hello C++ World\n";
              }
              

              with:

              $ g++ hello.cpp -o hello
              $ hello
              

              If this works then the compiler is fine.

              D Offline
              D Offline
              Daemonitas
              wrote on 18 May 2023, 13:39 last edited by Daemonitas
              #18

              @cristian-adam
              f7408a02-0917-46c3-8219-3f40dc271cca-image.png
              Compiler is working as intended

              @cristian-adam said in The C++ Compiler cannot run a simple test program:

              You could try with -G "MinGW Makefiles" instead of -G Ninja as CMake generator. But this should fail in a similar way.

              as for this yeah it results in an error

              and disabling windows defender also didn't solve it

              J 1 Reply Last reply 18 May 2023, 13:47
              0
              • D Daemonitas
                18 May 2023, 13:39

                @cristian-adam
                f7408a02-0917-46c3-8219-3f40dc271cca-image.png
                Compiler is working as intended

                @cristian-adam said in The C++ Compiler cannot run a simple test program:

                You could try with -G "MinGW Makefiles" instead of -G Ninja as CMake generator. But this should fail in a similar way.

                as for this yeah it results in an error

                and disabling windows defender also didn't solve it

                J Offline
                J Offline
                JonB
                wrote on 18 May 2023, 13:47 last edited by
                #19

                @Daemonitas
                I am dropping in on this thread rather late, so I may be missing something. But in the example you show works you use g++ as command, why are you using c++.exe in the stuff which fails?

                D 1 Reply Last reply 18 May 2023, 13:49
                0
                • J JonB
                  18 May 2023, 13:47

                  @Daemonitas
                  I am dropping in on this thread rather late, so I may be missing something. But in the example you show works you use g++ as command, why are you using c++.exe in the stuff which fails?

                  D Offline
                  D Offline
                  Daemonitas
                  wrote on 18 May 2023, 13:49 last edited by Daemonitas
                  #20

                  @JonB
                  for the example that works I just copied what @cristian-adam told me to try out

                  ill try using "c++"

                  edit:
                  1b8160ef-e275-4ab4-8163-5fcb2fe6c0d7-image.png
                  it also works

                  C J 2 Replies Last reply 18 May 2023, 14:08
                  0
                  • D Daemonitas
                    18 May 2023, 13:49

                    @JonB
                    for the example that works I just copied what @cristian-adam told me to try out

                    ill try using "c++"

                    edit:
                    1b8160ef-e275-4ab4-8163-5fcb2fe6c0d7-image.png
                    it also works

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

                    @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 1 Reply Last reply 18 May 2023, 14:28
                    0
                    • D Daemonitas
                      18 May 2023, 13:49

                      @JonB
                      for the example that works I just copied what @cristian-adam told me to try out

                      ill try using "c++"

                      edit:
                      1b8160ef-e275-4ab4-8163-5fcb2fe6c0d7-image.png
                      it also works

                      J Offline
                      J Offline
                      JonB
                      wrote on 18 May 2023, 14:15 last edited by JonB
                      #22

                      @Daemonitas
                      Google for: detecting c++ compiler abi info failed (your first error message). There are quite a few hits. For example https://stackoverflow.com/questions/64438728/detecting-compiler-abi-failed-by-cmake has:

                      There is a CMake project simple enough but not compiling at all with Visual Studio Code.

                      Not same as you since you are MinGW, and that one is on Linux not Windows. But maybe there is a clue in the various hits?

                      What about https://stackoverflow.com/questions/48141492/cmake-with-mingw-on-windows-10-detecting-cxx-compiler-abi-info-failed, that's MinGW?

                      1 Reply Last reply
                      0
                      • 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

                                          22/47

                                          18 May 2023, 14:15

                                          • Login

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