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
Forum Updated to NodeBB v4.3 + New Features

The C++ Compiler cannot run a simple test program

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
47 Posts 6 Posters 12.2k 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.
  • D Daemonitas

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

    goldenhawkingG Offline
    goldenhawkingG Offline
    goldenhawking
    wrote on 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

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

      cristian-adamC Offline
      cristian-adamC Offline
      cristian-adam
      wrote on 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
      0
      • cristian-adamC cristian-adam

        @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 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

        cristian-adamC 1 Reply Last reply
        0
        • D Daemonitas

          @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

          cristian-adamC Offline
          cristian-adamC Offline
          cristian-adam
          wrote on 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
          0
          • cristian-adamC cristian-adam

            @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 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

            JonBJ 1 Reply Last reply
            0
            • D Daemonitas

              @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

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on 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
              0
              • JonBJ JonB

                @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 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

                cristian-adamC JonBJ 2 Replies Last reply
                0
                • D Daemonitas

                  @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

                  cristian-adamC Offline
                  cristian-adamC Offline
                  cristian-adam
                  wrote on 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
                  0
                  • D Daemonitas

                    @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

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on 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
                    • cristian-adamC cristian-adam

                      @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 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

                      cristian-adamC O 2 Replies Last reply
                      0
                      • D Daemonitas

                        @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

                        cristian-adamC Offline
                        cristian-adamC Offline
                        cristian-adam
                        wrote on 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
                        • cristian-adamC Offline
                          cristian-adamC Offline
                          cristian-adam
                          wrote on 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
                          0
                          • cristian-adamC cristian-adam

                            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 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

                            cristian-adamC 1 Reply Last reply
                            0
                            • D Daemonitas

                              @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

                              cristian-adamC Offline
                              cristian-adamC Offline
                              cristian-adam
                              wrote on 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
                              0
                              • cristian-adamC cristian-adam

                                @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 last edited by
                                #28

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

                                cristian-adamC 1 Reply Last reply
                                0
                                • D Daemonitas

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

                                  cristian-adamC Offline
                                  cristian-adamC Offline
                                  cristian-adam
                                  wrote on 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
                                  0
                                  • cristian-adamC cristian-adam

                                    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 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

                                    cristian-adamC 1 Reply Last reply
                                    0
                                    • D Daemonitas

                                      @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

                                      cristian-adamC Offline
                                      cristian-adamC Offline
                                      cristian-adam
                                      wrote on 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
                                      0
                                      • cristian-adamC cristian-adam

                                        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 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
                                        • cristian-adamC Offline
                                          cristian-adamC Offline
                                          cristian-adam
                                          wrote on 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.

                                          cristian-adamC 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