Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT + Cmake + GTest = Test end up to be fatal
Forum Update on Monday, May 27th 2025

QT + Cmake + GTest = Test end up to be fatal

Scheduled Pinned Locked Moved Unsolved General and Desktop
cmakegtestfatalcpp
21 Posts 3 Posters 3.6k 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.
  • SGaistS SGaist

    Hi,

    Do you mean that if the test is empty is works ?

    BDC_PatrickB Offline
    BDC_PatrickB Offline
    BDC_Patrick
    wrote on last edited by
    #3

    @SGaist Did not test it with an empty TEST().. Did it now... Fatal Crash.. like before.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Where are the GTest .dlls located ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      BDC_PatrickB 1 Reply Last reply
      0
      • SGaistS SGaist

        Where are the GTest .dlls located ?

        BDC_PatrickB Offline
        BDC_PatrickB Offline
        BDC_Patrick
        wrote on last edited by
        #5

        @SGaist Gtest is installed via msys2 (mingw64 mode)
        There is the location of the libraries and includes.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #6

          Is the folder containing them in the PATH environment variable ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          BDC_PatrickB 1 Reply Last reply
          0
          • SGaistS SGaist

            Is the folder containing them in the PATH environment variable ?

            BDC_PatrickB Offline
            BDC_PatrickB Offline
            BDC_Patrick
            wrote on last edited by BDC_Patrick
            #7

            @SGaist Yes.. and GTEST_FOUND is true...

            I updated the Original Post.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              How did you install Qt ?

              It looks like you might be using two different compilers so I wonder if there's some bad interactions there.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              BDC_PatrickB 1 Reply Last reply
              1
              • SGaistS SGaist

                How did you install Qt ?

                It looks like you might be using two different compilers so I wonder if there's some bad interactions there.

                BDC_PatrickB Offline
                BDC_PatrickB Offline
                BDC_Patrick
                wrote on last edited by BDC_Patrick
                #9

                @SGaist via installer (not repo).
                The project is created via QT Creator as CMake Project.

                These are the Initial Cmake Parameters:

                -GNinja
                -DCMAKE_BUILD_TYPE:String=Debug
                -DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
                -DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
                -DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
                -DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
                
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  Which version of MinGW and Qt are you using ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • KH-219DesignK Offline
                    KH-219DesignK Offline
                    KH-219Design
                    wrote on last edited by
                    #11

                    It looks like you might be using two different compilers so I wonder if there's some bad interactions there

                    I think the conjecture by @SGaist likely has a lot of merit.

                    Here is some "general information" about Googletest. (I'm just the messenger! As the saying goes, don't shoot the messenger!)

                    Google developers have stated that they do not recommend using precompiled/prepackaged googletest binaries.

                    Instead, building googletest from source in a project you configure yourself is actually recommended by Google. And for certain kinds of more elaborate tests, I have been bitten by not complying. (strange linker errors was usually the result, if I recall)

                    Moreover, it is important that you compile Googletest with the same compiler and compiler flags as the test you are writing.

                    https://github.com/google/googletest/issues/2184

                    Building it yourself is fairly straightforward. Just list all the googletest *cc files in a makefile of whatever style you prefer (qmake, CMake, gnu make, vcxproj) and build as usual.

                    Here is a (working) example of this in qmake fashion:

                    https://github.com/219-design/qt-qml-project-template-with-ci/blob/22788b057/third_party/googletest-release-1.8.0/googletest/googletest.pro

                    www.219design.com
                    Software | Electrical | Mechanical | Product Design

                    BDC_PatrickB 2 Replies Last reply
                    1
                    • KH-219DesignK KH-219Design

                      It looks like you might be using two different compilers so I wonder if there's some bad interactions there

                      I think the conjecture by @SGaist likely has a lot of merit.

                      Here is some "general information" about Googletest. (I'm just the messenger! As the saying goes, don't shoot the messenger!)

                      Google developers have stated that they do not recommend using precompiled/prepackaged googletest binaries.

                      Instead, building googletest from source in a project you configure yourself is actually recommended by Google. And for certain kinds of more elaborate tests, I have been bitten by not complying. (strange linker errors was usually the result, if I recall)

                      Moreover, it is important that you compile Googletest with the same compiler and compiler flags as the test you are writing.

                      https://github.com/google/googletest/issues/2184

                      Building it yourself is fairly straightforward. Just list all the googletest *cc files in a makefile of whatever style you prefer (qmake, CMake, gnu make, vcxproj) and build as usual.

                      Here is a (working) example of this in qmake fashion:

                      https://github.com/219-design/qt-qml-project-template-with-ci/blob/22788b057/third_party/googletest-release-1.8.0/googletest/googletest.pro

                      BDC_PatrickB Offline
                      BDC_PatrickB Offline
                      BDC_Patrick
                      wrote on last edited by
                      #12

                      @KH-219Design alright.. I will try to compile it from the Repo by myself today..
                      wish me luck 🙈

                      1 Reply Last reply
                      0
                      • KH-219DesignK KH-219Design

                        It looks like you might be using two different compilers so I wonder if there's some bad interactions there

                        I think the conjecture by @SGaist likely has a lot of merit.

                        Here is some "general information" about Googletest. (I'm just the messenger! As the saying goes, don't shoot the messenger!)

                        Google developers have stated that they do not recommend using precompiled/prepackaged googletest binaries.

                        Instead, building googletest from source in a project you configure yourself is actually recommended by Google. And for certain kinds of more elaborate tests, I have been bitten by not complying. (strange linker errors was usually the result, if I recall)

                        Moreover, it is important that you compile Googletest with the same compiler and compiler flags as the test you are writing.

                        https://github.com/google/googletest/issues/2184

                        Building it yourself is fairly straightforward. Just list all the googletest *cc files in a makefile of whatever style you prefer (qmake, CMake, gnu make, vcxproj) and build as usual.

                        Here is a (working) example of this in qmake fashion:

                        https://github.com/219-design/qt-qml-project-template-with-ci/blob/22788b057/third_party/googletest-release-1.8.0/googletest/googletest.pro

                        BDC_PatrickB Offline
                        BDC_PatrickB Offline
                        BDC_Patrick
                        wrote on last edited by BDC_Patrick
                        #13

                        @KH-219Design ok.. i´ve no clue how to build an integrate gtest into my project.. all that cmd stuff and that google manual is more cryptic to me than helpful...

                        I really need help here..

                        I cloned the Repo,
                        in powershell:

                        $ cd googletest
                        $ mkdir gtest_build
                        $ cd gtest_build
                        $ cmake ..
                        

                        And now?

                        1 Reply Last reply
                        0
                        • KH-219DesignK Offline
                          KH-219DesignK Offline
                          KH-219Design
                          wrote on last edited by
                          #14

                          @BDC_Patrick

                          So... I cannot possibly blame you for the approach that you took (which is essentially to follow the Googletest manual for how to do their equivalent of "make; make install"). That was a sane assumption on your part.

                          However, that was not what I actually intended to recommend. (Nor what I have done to make googletest work for me in my C++ projects).

                          What I was saying is to get all the source code for googletest, then create your own Makefile from scratch (be it a qmake pro file, or a CMakeLists.txt, or a vcxproj). Just take the C++ source files from googletest and write a library buildfile in your own preferred Makefile system to build those C++ source files.

                          In other words, you imagine that you have just personally created all these sources (gtest-all.cc, gtest-death-test.cc, gtest-filepath.cc, etc), and you do "whatever you normally do after writing a C++ class" in terms of adding that C++ class/file to your build.

                          Do you know how: (a) to use CMake to compile a shared library (either a DLL or an *.so)?

                          And then after that, do you know how to (b) use CMake to compile an exe that links against the shared library from step (a)?

                          Knowing about (a) and (b) and prerequisites to the path forward that I am suggesting. So perhaps I got ahead of myself by not making sure you are confident in how to do (a) and (b).

                          www.219design.com
                          Software | Electrical | Mechanical | Product Design

                          BDC_PatrickB 1 Reply Last reply
                          0
                          • KH-219DesignK KH-219Design

                            @BDC_Patrick

                            So... I cannot possibly blame you for the approach that you took (which is essentially to follow the Googletest manual for how to do their equivalent of "make; make install"). That was a sane assumption on your part.

                            However, that was not what I actually intended to recommend. (Nor what I have done to make googletest work for me in my C++ projects).

                            What I was saying is to get all the source code for googletest, then create your own Makefile from scratch (be it a qmake pro file, or a CMakeLists.txt, or a vcxproj). Just take the C++ source files from googletest and write a library buildfile in your own preferred Makefile system to build those C++ source files.

                            In other words, you imagine that you have just personally created all these sources (gtest-all.cc, gtest-death-test.cc, gtest-filepath.cc, etc), and you do "whatever you normally do after writing a C++ class" in terms of adding that C++ class/file to your build.

                            Do you know how: (a) to use CMake to compile a shared library (either a DLL or an *.so)?

                            And then after that, do you know how to (b) use CMake to compile an exe that links against the shared library from step (a)?

                            Knowing about (a) and (b) and prerequisites to the path forward that I am suggesting. So perhaps I got ahead of myself by not making sure you are confident in how to do (a) and (b).

                            BDC_PatrickB Offline
                            BDC_PatrickB Offline
                            BDC_Patrick
                            wrote on last edited by
                            #15

                            @KH-219Design
                            (a) no
                            (b) not yet

                            But i think i found a way, to fetch the latest repo of googletest and include it. That worked well..

                            Still got a FATAL Problem at the Test Result Window, which seems to be a QT Creator Problem, since it isn´t able to run Tests.exe, but gives out (correct) Test Results. More, the Tests.exe can be started (via a batch that adds the QT dll location to PATH) and gives a perfect Powershell output of all Test.

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #16

                              Is it still the same error ?

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              BDC_PatrickB 1 Reply Last reply
                              0
                              • KH-219DesignK Offline
                                KH-219DesignK Offline
                                KH-219Design
                                wrote on last edited by
                                #17

                                @BDC_Patrick said in QT + Cmake + GTest = Test end up to be fatal:

                                it isn´t able to run Tests.exe, but gives out (correct) Test Results

                                what the h...??

                                how could anything output correct test results without running Tests.exe??

                                It seems like you are making progress little by little, so I am happy for you! I'll take slow and tiny progress over no progress any day :)

                                www.219design.com
                                Software | Electrical | Mechanical | Product Design

                                1 Reply Last reply
                                0
                                • SGaistS SGaist

                                  Is it still the same error ?

                                  BDC_PatrickB Offline
                                  BDC_PatrickB Offline
                                  BDC_Patrick
                                  wrote on last edited by BDC_Patrick
                                  #18

                                  @SGaist The Error says:
                                  Fatal.jpg

                                  But as i said, The Test run though completely and there is no such FATAL Error in Powershell, cmd or the Console-View of QT Creator Test Result.

                                  See:
                                  Fatal2.jpeg
                                  Fatal3.jpeg
                                  No FATAL Error here...
                                  Test runn Through

                                  Btw.. The Batch i run the Tests.exe from:

                                  @
                                  set PATH=C:\Qt\5.15.2\mingw81_64\bin;%PATH%
                                  start PowerShell -NoExit -Command "[Path\To\Build\Folder]\Tests.exe"
                                  @
                                  
                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #19

                                    I think you have an interpretation error here. Your tests executable ran successfully so to say. The fatal here means that one or more of your tests failed.

                                    If it had crashed you would not see it in the report panel but you would have a dialog stating that there was a crash.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    BDC_PatrickB 1 Reply Last reply
                                    2
                                    • SGaistS SGaist

                                      I think you have an interpretation error here. Your tests executable ran successfully so to say. The fatal here means that one or more of your tests failed.

                                      If it had crashed you would not see it in the report panel but you would have a dialog stating that there was a crash.

                                      BDC_PatrickB Offline
                                      BDC_PatrickB Offline
                                      BDC_Patrick
                                      wrote on last edited by
                                      #20

                                      @SGaist sooo..? Need for a fix.. or.. is there a fix?

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #21

                                        Well, there's nothing to fix, the output matches what your test does.

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        1

                                        • Login

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