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. Build Qt cmake project without Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Build Qt cmake project without Qt Creator

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 2.3k 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.
  • Dmitry87D Offline
    Dmitry87D Offline
    Dmitry87
    wrote on last edited by
    #1

    I'm trying to build "Lights example" from windows console.

    I'm using these 2 command lines:

    "S:/Qt601/Tools/CMake_64/bin/cmake.exe" -S S:/Qt601/Examples/Qt-6.0.1/quick3d/lights -B S:/Qt601/Examples/Qt-6.0.1/quick3d/build-lights-Desktop_Qt_6_0_1_MinGW_64_bit-Debug -GNinja "-DCMAKE_BUILD_TYPE:String=Debug" "-DQT_QMAKE_EXECUTABLE:STRING=S:/Qt601/6.0.1/mingw81_64/bin/qmake.exe" "-DCMAKE_PREFIX_PATH:STRING=S:/Qt601/6.0.1/mingw81_64" "-DCMAKE_C_COMPILER:STRING=S:/Qt601/Tools/mingw810_64/bin/gcc.exe" "-DCMAKE_CXX_COMPILER:STRING=S:/Qt601/Tools/mingw810_64/bin/g++.exe"
    
    "S:/Qt601/Tools/CMake_64/bin/cmake.exe" --build . --target all
    

    The first line I copied from Qt Creator and while in the creator there are no errors, when I execute this line manually from console I get this error:

    -- The CXX compiler identification is unknown
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - failed
    -- Check for working CXX compiler: S:/Qt601/Tools/mingw810_64/bin/g++.exe
    -- Check for working CXX compiler: S:/Qt601/Tools/mingw810_64/bin/g++.exe - broken
    CMake Error at S:/Qt601/Tools/CMake_64/share/cmake-3.19/Modules/CMakeTestCXXCompiler.cmake:59 (message):
      The C++ compiler
    
        "S:/Qt601/Tools/mingw810_64/bin/g++.exe"
    
      is not able to compile a simple test program.
      It fails with the following output:
    
        Change Dir: S:/Qt601/Examples/Qt-6.0.1/quick3d/build-lights-Desktop_Qt_6_0_1_MinGW_64_bit-Debug/CMakeFiles/CMakeTmp
    
        Run Build Command(s):S:/Qt601/Tools/Ninja/ninja.exe cmTC_bca0c && [1/2] Building CXX object CMakeFiles\cmTC_bca0c.dir\testCXXCompiler.cxx.obj
        FAILED: CMakeFiles/cmTC_bca0c.dir/testCXXCompiler.cxx.obj
        S:\Qt601\Tools\mingw810_64\bin\g++.exe    -o CMakeFiles\cmTC_bca0c.dir\testCXXCompiler.cxx.obj -c testCXXCompiler.cxx
        ninja: build stopped: subcommand failed.
    
      CMake will not be able to correctly generate this project.
    Call Stack (most recent call first):
      CMakeLists.txt:4 (project)
    
    -- Configuring incomplete, errors occurred!
    See also "S:/Qt601/Examples/Qt-6.0.1/quick3d/build-lights-Desktop_Qt_6_0_1_MinGW_64_bit-Debug/CMakeFiles/CMakeOutput.log".
    See also "S:/Qt601/Examples/Qt-6.0.1/quick3d/build-lights-Desktop_Qt_6_0_1_MinGW_64_bit-Debug/CMakeFiles/CMakeError.log".
    

    CMakeOutput.log is empty and here is CMakeError.log https://drive.google.com/file/d/1UFahipkoZa-J_3KmjNy1ECVKf4uzQS4K/view?usp=sharing

    Also If I run the second line after the first one is executed in Qt Creator I get this error:

    Error: could not load cache
    

    I execute both commands from project directory.
    What am I doing wrong? Google gives no information that could help.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wrosecrans
      wrote on last edited by
      #2

      @Dmitry87 said in Build Qt cmake project without Qt Creator:

      S:/Qt601/Tools/mingw810_64/bin/g++.exe

      What happens when you try to just build a trivial test .cpp file with that compiler without using CMake?

      Dmitry87D 1 Reply Last reply
      1
      • W wrosecrans

        @Dmitry87 said in Build Qt cmake project without Qt Creator:

        S:/Qt601/Tools/mingw810_64/bin/g++.exe

        What happens when you try to just build a trivial test .cpp file with that compiler without using CMake?

        Dmitry87D Offline
        Dmitry87D Offline
        Dmitry87
        wrote on last edited by
        #3

        @wrosecrans It shows a message box with "The program can't start because libwinpthread-1.dll is missing"

        aha_1980A 1 Reply Last reply
        0
        • Dmitry87D Dmitry87

          @wrosecrans It shows a message box with "The program can't start because libwinpthread-1.dll is missing"

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Dmitry87 you need to properly set up the environment.

          First you could open a Terminal from Creator with Build Environment (right click a file in your Projects side bar e.g.).

          Regards

          Qt has to stay free or it will die.

          Dmitry87D 1 Reply Last reply
          0
          • aha_1980A aha_1980

            @Dmitry87 you need to properly set up the environment.

            First you could open a Terminal from Creator with Build Environment (right click a file in your Projects side bar e.g.).

            Regards

            Dmitry87D Offline
            Dmitry87D Offline
            Dmitry87
            wrote on last edited by Dmitry87
            #5

            @aha_1980
            Is there an instruction? I'm not sure if I understend your recomendation. If I can build the project from Qt Creator, why the environment setup is incorrect?
            Isn't it a problem in the command line which I use to build the project from windows cmd?
            I tried to build the project from the terminal, opened from creator, but still get these errors.

            aha_1980A 1 Reply Last reply
            0
            • Dmitry87D Dmitry87

              @aha_1980
              Is there an instruction? I'm not sure if I understend your recomendation. If I can build the project from Qt Creator, why the environment setup is incorrect?
              Isn't it a problem in the command line which I use to build the project from windows cmd?
              I tried to build the project from the terminal, opened from creator, but still get these errors.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Dmitry87

              I tried to build the project from the terminal, opened from creator, but still get these errors.

              And you did open a terminal with build environment?

              How does the path inside this terminal look like?

              Regards

              Qt has to stay free or it will die.

              Dmitry87D 1 Reply Last reply
              0
              • aha_1980A aha_1980

                @Dmitry87

                I tried to build the project from the terminal, opened from creator, but still get these errors.

                And you did open a terminal with build environment?

                How does the path inside this terminal look like?

                Regards

                Dmitry87D Offline
                Dmitry87D Offline
                Dmitry87
                wrote on last edited by Dmitry87
                #7

                @aha_1980
                Pardon, apparently I did something wrong, the first error has gone. Now it shows this message for the first line:

                -- Looking for C++ include pthread.h
                -- Looking for C++ include pthread.h - found
                -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
                -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
                -- Found Threads: TRUE
                -- Performing Test HAVE_STDATOMIC
                -- Performing Test HAVE_STDATOMIC - Success
                -- Found WrapAtomic: TRUE
                -- Found Vulkan: S:/VulkanSDK/1.2.154.1/Lib/vulkan-1.lib
                -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
                -- Could NOT find WrapOpenSSLHeaders (missing: WrapOpenSSLHeaders_FOUND)
                -- Configuring done
                -- Generating done
                CMake Warning:
                  Manually-specified variables were not used by the project:
                    QT_QMAKE_EXECUTABLE
                -- Build files have been written to: S:/Qt601/Examples/Qt-6.0.1/quick3d/build-lights-Desktop_Qt_6_0_1_MinGW_64_bit-Debug
                

                That seems to be OK.
                For the second line I still get this error:

                Error: could not load cache
                

                The path in terminal is: "S:\Qt601\Examples\Qt-6.0.1\quick3d\lights"

                aha_1980A 1 Reply Last reply
                0
                • Dmitry87D Dmitry87

                  @aha_1980
                  Pardon, apparently I did something wrong, the first error has gone. Now it shows this message for the first line:

                  -- Looking for C++ include pthread.h
                  -- Looking for C++ include pthread.h - found
                  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
                  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
                  -- Found Threads: TRUE
                  -- Performing Test HAVE_STDATOMIC
                  -- Performing Test HAVE_STDATOMIC - Success
                  -- Found WrapAtomic: TRUE
                  -- Found Vulkan: S:/VulkanSDK/1.2.154.1/Lib/vulkan-1.lib
                  -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
                  -- Could NOT find WrapOpenSSLHeaders (missing: WrapOpenSSLHeaders_FOUND)
                  -- Configuring done
                  -- Generating done
                  CMake Warning:
                    Manually-specified variables were not used by the project:
                      QT_QMAKE_EXECUTABLE
                  -- Build files have been written to: S:/Qt601/Examples/Qt-6.0.1/quick3d/build-lights-Desktop_Qt_6_0_1_MinGW_64_bit-Debug
                  

                  That seems to be OK.
                  For the second line I still get this error:

                  Error: could not load cache
                  

                  The path in terminal is: "S:\Qt601\Examples\Qt-6.0.1\quick3d\lights"

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Dmitry87 I meant the PATH environment variable. You need to set it if you want to build outside Creator, which automatically does it for you.

                  Qt has to stay free or it will die.

                  Dmitry87D 1 Reply Last reply
                  0
                  • aha_1980A aha_1980

                    @Dmitry87 I meant the PATH environment variable. You need to set it if you want to build outside Creator, which automatically does it for you.

                    Dmitry87D Offline
                    Dmitry87D Offline
                    Dmitry87
                    wrote on last edited by
                    #9

                    @aha_1980

                    PATH=S:\Qt601\Tools\mingw810_64\bin;C:\Windows;S:\Qt601\Tools\Ninja;C:\MinGW\bin;C:\Windows\SysWOW64\WindowsPowerShell\v1.0
                    
                    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