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.3k 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.
  • J.HilkJ J.Hilk

    @Daemonitas
    This error message is usually caused by a permission issue. You can try running QtCreator as an administrator or check if the file is locked by another process.

    D Offline
    D Offline
    Daemonitas
    wrote on last edited by
    #3

    @J-Hilk
    Hello, thanks for the reply it still doesn't work. I even tried putting the project in the same drive as Qt but it's also showing the same error. The build button has been disabled ever since I installed Qt

    J.HilkJ 1 Reply Last reply
    0
    • D Daemonitas

      @J-Hilk
      Hello, thanks for the reply it still doesn't work. I even tried putting the project in the same drive as Qt but it's also showing the same error. The build button has been disabled ever since I installed Qt

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

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

      I even tried putting the project in the same drive as Qt but it's also showing the same error

      thats totally unrelated to what I suggested.

      it still doesn't work.

      I take your word for it.

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

      The build button has been disabled ever since I installed Qt

      that you didn't mention, nor show in your screenshot!

      open the qtCreator settings/preferences and select the kits tab.

      Hover with your mouse over detected kit, it probably has a yellow warning triangle or a red ! in a circle.

      A tooltip will popup telling you what issues there are with your kits. Try to fix those


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


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

      D 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

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

        I even tried putting the project in the same drive as Qt but it's also showing the same error

        thats totally unrelated to what I suggested.

        it still doesn't work.

        I take your word for it.

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

        The build button has been disabled ever since I installed Qt

        that you didn't mention, nor show in your screenshot!

        open the qtCreator settings/preferences and select the kits tab.

        Hover with your mouse over detected kit, it probably has a yellow warning triangle or a red ! in a circle.

        A tooltip will popup telling you what issues there are with your kits. Try to fix those

        D Offline
        D Offline
        Daemonitas
        wrote on last edited by
        #5

        @J-Hilk
        They look perfectly fine
        abfb2204-f65e-42fa-9f15-e634f251d0ca-image.png

        J.HilkJ 1 Reply Last reply
        0
        • D Daemonitas

          @J-Hilk
          They look perfectly fine
          abfb2204-f65e-42fa-9f15-e634f251d0ca-image.png

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

          @Daemonitas interesting, I did not expect that :D

          what tool tip do you get when you hover over "untitled6" in your project settings

          or when you select "Project" on the left hand menu bar?


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


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

          D 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @Daemonitas interesting, I did not expect that :D

            what tool tip do you get when you hover over "untitled6" in your project settings

            or when you select "Project" on the left hand menu bar?

            D Offline
            D Offline
            Daemonitas
            wrote on last edited by
            #7

            @J-Hilk
            So i tried with all the kits available
            7dea09a7-ed33-46ee-a0b5-f2f016bfe607-image.png
            Most of them missing build type "Debug"
            and
            f1eac6a4-9ef5-4746-812e-ba984f0ae24c-image.png
            this one missing "RelWithDebInfo"

            1 Reply Last reply
            0
            • cristian-adamC Offline
              cristian-adamC Offline
              cristian-adam
              wrote on last edited by
              #8

              At first I thought that the whitespace in the project directory path could pose an issue.

              I've tested locally and worked fine.

              Which CMake version are you using?

              The missing build type configuration like Debug or RelWithDebInfo means that CMake didn't export the project configuration in json file format.

              D 1 Reply Last reply
              0
              • cristian-adamC cristian-adam

                At first I thought that the whitespace in the project directory path could pose an issue.

                I've tested locally and worked fine.

                Which CMake version are you using?

                The missing build type configuration like Debug or RelWithDebInfo means that CMake didn't export the project configuration in json file format.

                D Offline
                D Offline
                Daemonitas
                wrote on last edited by
                #9

                @cristian-adam
                I'm using CMake 3.24.2
                61797464-0232-483d-9369-aa5e7583e26d-image.png

                cristian-adamC 1 Reply Last reply
                0
                • D Daemonitas

                  @cristian-adam
                  I'm using CMake 3.24.2
                  61797464-0232-483d-9369-aa5e7583e26d-image.png

                  cristian-adamC Offline
                  cristian-adamC Offline
                  cristian-adam
                  wrote on last edited by
                  #10

                  Everything looks fine! There shouldn't be a reason why ninja would fail.

                  I have a similar setup, and the only visible difference is that I use: c:\Projects\C++ as a very short path.

                  Do you have LongPathsEnabled under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem ? As per MSDN: Maximum Path Length Limitation.

                  Any special antivirus program running?

                  My next approach would be to try from a cmd.exe Window the same commands that Qt Creator is doing, for MinGW it should be easier:

                  $ 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
                  $ cd D:/programm/C++ Homework Sem 2/untitled6
                  $ cmake -S . -B build -DCMAKE_PREFIX_PATH=C:/Qt/6.5.0/mingw_64  -DCMAKE_BUILD_TYPE=Release
                  $ cmake --build build
                  D 1 Reply Last reply
                  0
                  • cristian-adamC cristian-adam

                    Everything looks fine! There shouldn't be a reason why ninja would fail.

                    I have a similar setup, and the only visible difference is that I use: c:\Projects\C++ as a very short path.

                    Do you have LongPathsEnabled under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem ? As per MSDN: Maximum Path Length Limitation.

                    Any special antivirus program running?

                    My next approach would be to try from a cmd.exe Window the same commands that Qt Creator is doing, for MinGW it should be easier:

                    $ 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
                    $ cd D:/programm/C++ Homework Sem 2/untitled6
                    $ cmake -S . -B build -DCMAKE_PREFIX_PATH=C:/Qt/6.5.0/mingw_64  -DCMAKE_BUILD_TYPE=Release
                    $ cmake --build build
                    D Offline
                    D Offline
                    Daemonitas
                    wrote on last edited by
                    #11

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

                    Do you have LongPathsEnabled under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem ? As per MSDN: Maximum Path Length Limitation.

                    I just enabled it in Registry editor

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

                    Any special antivirus program running?

                    Just windows defender

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

                    moc --version

                    Tried to run this in cmd but it appears that i don't have it on my laptop since it said that it is not recognized as an internal or external command

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

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

                    apparently I do not have this "CMakeList.txt." its looking for

                    78cba11e-1a6e-4353-9e31-919c35be1c98-image.png

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

                    $ cmake --build build

                    and this one resulted in an error too

                    493597fe-a99c-474f-a975-b01e5f9d1036-image.png

                    cristian-adamC 1 Reply Last reply
                    0
                    • D Daemonitas

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

                      Do you have LongPathsEnabled under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem ? As per MSDN: Maximum Path Length Limitation.

                      I just enabled it in Registry editor

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

                      Any special antivirus program running?

                      Just windows defender

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

                      moc --version

                      Tried to run this in cmd but it appears that i don't have it on my laptop since it said that it is not recognized as an internal or external command

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

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

                      apparently I do not have this "CMakeList.txt." its looking for

                      78cba11e-1a6e-4353-9e31-919c35be1c98-image.png

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

                      $ cmake --build build

                      and this one resulted in an error too

                      493597fe-a99c-474f-a975-b01e5f9d1036-image.png

                      cristian-adamC Offline
                      cristian-adamC Offline
                      cristian-adam
                      wrote on last edited by
                      #12

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

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

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

                        goldenhawkingG cristian-adamC 2 Replies 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 (?)

                          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

                                          • Login

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