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 and Run gRPC Server for Magic 8 Ball Example on Windows

Build and Run gRPC Server for Magic 8 Ball Example on Windows

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.0k Views 2 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.
  • G Offline
    G Offline
    greed_14
    wrote on last edited by
    #1

    Hi,

    I’ve installed Qt 6.9.1 on my Windows machine and have the MinGW kit set up. I’m currently exploring the gRPC examples to better understand how it works before integrating it into our application.

    When I build the Magic 8 Ball example, the client application runs successfully. However, I also need to build and run the server, which is a console application. How can I build and run the server on my Windows system?

    Regards,
    Adnan

    1 Reply Last reply
    0
    • G Offline
      G Offline
      greed_14
      wrote on last edited by
      #9

      Hi,

      Thanks for your response.

      I was able to get it working by using the MSVC kit.

      Here are the steps I followed, in case anyone else encounters the same issue:

      1. Installed MSVC 2022 C++ for Desktop, which allowed Qt Creator to auto-detect the MSVC compilers.

      2. Cloned and bootstrapped vcpkg, then installed the required package:

      git clone https://github.com/microsoft/vcpkg.git
      cd vcpkg
      .\bootstrap-vcpkg.bat
      
      .\vcpkg.exe install grpc --triplet x64-windows
      
      
      1. Selected the amd64 compiler in Qt Creator.

      2. Updated my CMake configuration as follows:

      -DCMAKE_TOOLCHAIN_FILE:UNINITIALIZED=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
      -DVCPKG_TARGET_TRIPLET:UNINITIALIZED=x64-windows
      -DQT_USE_VCPKG:UNINITIALIZED=ON
      

      both server and client binaries were present in the same build directory.

      Regards,
      Adnan

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

        Hi,

        You can do it from Qt Creator as with the client application.

        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
        • G Offline
          G Offline
          greed_14
          wrote on last edited by greed_14
          #3

          Hi,

          Below is my cmake output and build error.
          I have installed protobuf and grpc using vcpkg

          [cmake] Running C:\Qt\Tools\CMake_64\bin\cmake.exe -S C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball -B C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug "-DCMAKE_PREFIX_PATH:PATH=C:/Qt/6.9.1/mingw_64" "-DCMAKE_CXX_COMPILER:FILEPATH=C:/Qt/Tools/mingw1310_64/bin/g++.exe" "-DCMAKE_CXX_FLAGS_INIT:STRING=-DQT_QML_DEBUG" "-DCMAKE_BUILD_TYPE:STRING=Debug" "-DQT_USE_VCPKG:UNINITIALIZED=TRUE" "-DCMAKE_GENERATOR:STRING=Ninja" "-DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON" "-DQT_MAINTENANCE_TOOL:FILEPATH=C:/Qt/MaintenanceTool.exe" "-DQT_QMAKE_EXECUTABLE:FILEPATH=C:/Qt/6.9.1/mingw_64/bin/qmake.exe" "-DVCPKG_ROOT:UNINITIALIZED=C:\vcpkg" "-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=C:\Qt\Examples\Qt-6.9.1\grpc\magic8ball\build\Desktop_Qt_6_9_1_MinGW_64_bit-Debug/.qtc/package-manager/auto-setup.cmake" "-DCMAKE_C_COMPILER:FILEPATH=C:/Qt/Tools/mingw1310_64/bin/gcc.exe" "-DCMAKE_TOOLCHAIN_FILE:UNINITIALIZED=C:\vcpkg\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET:UNINITIALIZED=x64-windows" "-DVCPKG_TOOLCHAIN_FILE:UNINITIALIZED=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" in C:\Qt\Examples\Qt-6.9.1\grpc\magic8ball\build\Desktop_Qt_6_9_1_MinGW_64_bit-Debug.
          [cmake] CMake Warning at build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/.qtc/package-manager/auto-setup.cmake:267 (message):
          [cmake]   Qt Creator: vcpkg executable not found.  Package manager auto-setup will be
          [cmake]   skipped.  To disable this warning set QT_CREATOR_SKIP_VCPKG_SETUP to ON.
          [cmake] Call Stack (most recent call first):
          [cmake]   build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/.qtc/package-manager/auto-setup.cmake:371 (qtc_auto_setup_vcpkg)
          [cmake]   CMakeLists.txt:5 (project)
          [cmake] 
          [cmake] 
          [cmake] -- Running vcpkg install
          [cmake] Detecting compiler hash for triplet x64-windows...
          [cmake] Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe
          [cmake] The following packages are already installed:
          [cmake]   * abseil[core,cxx17]:x64-windows@20250127.1#3
          [cmake]   * c-ares:x64-windows@1.34.5
          [cmake]     grpc[codegen,core]:x64-windows@1.71.0#2
          [cmake]   * openssl:x64-windows@3.5.1
          [cmake]     protobuf:x64-windows@5.29.5#1
          [cmake]   * re2:x64-windows@2025-08-05
          [cmake]   * utf8-range:x64-windows@5.29.5
          [cmake]   * vcpkg-cmake:x64-windows@2024-04-23
          [cmake]   * vcpkg-cmake-config:x64-windows@2024-05-23
          [cmake]   * vcpkg-cmake-get-vars:x64-windows@2025-05-29
          [cmake]   * zlib:x64-windows@1.3.1
          [cmake] protobuf provides CMake targets:
          [cmake] 
          [cmake]   # this is heuristically generated, and may not be correct
          [cmake]   find_package(protobuf CONFIG REQUIRED)
          [cmake]   target_link_libraries(main PRIVATE protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite)
          [cmake] 
          [cmake] protobuf provides pkg-config modules:
          [cmake] 
          [cmake]   # Google's Data Interchange Format
          [cmake]   protobuf-lite
          [cmake] 
          [cmake]   # Google's Data Interchange Format
          [cmake]   protobuf
          [cmake] 
          [cmake] grpc provides CMake targets:
          [cmake] 
          [cmake]   # this is heuristically generated, and may not be correct
          [cmake]   find_package(gRPC CONFIG REQUIRED)
          [cmake]   # note: 15 additional targets are not displayed.
          [cmake]   target_link_libraries(main PRIVATE gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc++_alts)
          [cmake] 
          [cmake] All requested installations completed successfully in: 1.36 ms
          [cmake] -- Running vcpkg install - done
          [cmake] -- The CXX compiler identification is GNU 13.1.0
          [cmake] -- Detecting CXX compiler ABI info
          [cmake] -- Detecting CXX compiler ABI info - done
          [cmake] -- Check for working CXX compiler: C:/Qt/Tools/mingw1310_64/bin/g++.exe - skipped
          [cmake] -- Detecting CXX compile features
          [cmake] -- Detecting CXX compile features - done
          [cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
          [cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
          [cmake] -- Found Threads: TRUE
          [cmake] -- Performing Test HAVE_STDATOMIC
          [cmake] -- Performing Test HAVE_STDATOMIC - Success
          [cmake] -- Found WrapAtomic: TRUE
          [cmake] -- Found WrapVulkanHeaders: C:/VulkanSDK/1.4.321.1/Include
          [cmake] CMake Warning at build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/.qtc/package-manager/auto-setup.cmake:267 (message):
          [cmake]   Qt Creator: vcpkg executable not found.  Package manager auto-setup will be
          [cmake]   skipped.  To disable this warning set QT_CREATOR_SKIP_VCPKG_SETUP to ON.
          [cmake] Call Stack (most recent call first):
          [cmake]   build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/.qtc/package-manager/auto-setup.cmake:371 (qtc_auto_setup_vcpkg)
          [cmake]   server/CMakeLists.txt:5 (project)
          [cmake] 
          [cmake] 
          [cmake] -- Found Protobuf: C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/vcpkg_installed/x64-windows/tools/protobuf/protoc.exe (found version "29.5.0")
          [cmake] -- Found ZLIB: optimized;C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/vcpkg_installed/x64-windows/lib/zlib.lib;debug;C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/vcpkg_installed/x64-windows/debug/lib/zlibd.lib (found version "1.3.1")
          [cmake] -- Found OpenSSL: C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/vcpkg_installed/x64-windows/debug/lib/libcrypto.lib (found version "3.5.1")
          [cmake] CMake Warning at server/CMakeLists.txt:26 (message):
          [cmake]   magic8ball_server uses reference grpc++ library that doesn't officially
          [cmake]   support MinGW.  Please use the MSVC compiler to build this example.  The
          [cmake]   correct work is not guaranteed otherwise.
          [cmake] 
          [cmake] 
          [cmake] -- Configuring done (8.5s)
          [cmake] -- Generating done (0.4s)
          [cmake] CMake Warning:
          [cmake]   Manually-specified variables were not used by the project:
          [cmake] 
          [cmake]     QT_MAINTENANCE_TOOL
          [cmake]     QT_USE_VCPKG
          [cmake]     VCPKG_ROOT
          [cmake]     VCPKG_TOOLCHAIN_FILE
          [cmake] 
          [cmake] 
          [cmake] -- Build files have been written to: C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug
          [cmake] 
          [cmake] Elapsed time: 00:09.
          
          

          Error:-

          00:13:00: Running steps for project Magic8Ball...
          00:13:00: Starting: "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug --target all
          [1/55 4.7/sec] Copying magic8ball qml resources into build dir
          [2/55 9.0/sec] Copying magic8ball qml sources into build dir
          [3/55 10.3/sec] Generating QtProtobuf magic8ball_plugin sources for qtprotobufgen...
          [4/55 13.2/sec] Generating QtProtobuf magic8ball_plugin sources for qtgrpcgen...
          [5/55 14.6/sec] Generating gRPC  sources...
          [6/55 7.8/sec] Automatic MOC and UIC for target magic8ball_server
          [7/55 7.8/sec] Running qmlimportscanner for magic8ball
          [8/55 8.6/sec] Automatic MOC and UIC for target magic8ball_plugin_qtprotoreg
          [9/55 9.0/sec] Building CXX object server/CMakeFiles/magic8ball_server.dir/magic8ball_server_autogen/mocs_compilation.cpp.obj
          [10/55 7.6/sec] Building CXX object CMakeFiles/magic8ball_plugin_qtprotoreg.dir/magic8ball_plugin_qtprotoreg_autogen/mocs_compilation.cpp.obj
          [11/55 4.5/sec] Automatic MOC and UIC for target magic8ball_pluginplugin
          [12/55 1.8/sec] Building CXX object server/CMakeFiles/magic8ball_server.dir/exampleservice.pb.cc.obj
          [13/55 1.8/sec] Building CXX object CMakeFiles/magic8ball_plugin_qtprotoreg.dir/exampleservice_qtprotoreg.cpp.obj
          [14/55 1.4/sec] Automatic MOC and UIC for target magic8ball_plugin
          [15/55 1.5/sec] Running AUTOMOC file extraction for target magic8ball_plugin
          [16/55 1.6/sec] Running rcc for resource qmake_qtgrpc_examples
          [17/55 1.7/sec] Running moc --collect-json for target magic8ball_plugin
          [18/55 1.8/sec] Automatic QML type registration for target magic8ball_plugin
          [19/55 1.8/sec] Building CXX object CMakeFiles/magic8ball_plugin.dir/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/.qt/rcc/qrc_qmake_qtgrpc_examples.cpp.obj
          [20/55 1.9/sec] Building CXX object server/CMakeFiles/magic8ball_server.dir/main.cpp.obj
          [21/55 1.7/sec] Building CXX object server/CMakeFiles/magic8ball_server.dir/exampleservice.grpc.pb.cc.obj
          [22/55 1.7/sec] Linking CXX executable magic8ball_server.exe
          FAILED: magic8ball_server.exe 
          C:\WINDOWS\system32\cmd.exe /C "cd . && C:\Qt\Tools\mingw1310_64\bin\g++.exe -DQT_QML_DEBUG -g  server/CMakeFiles/magic8ball_server.dir/magic8ball_server_autogen/mocs_compilation.cpp.obj server/CMakeFiles/magic8ball_server.dir/exampleservice.pb.cc.obj server/CMakeFiles/magic8ball_server.dir/exampleservice.grpc.pb.cc.obj server/CMakeFiles/magic8ball_server.dir/main.cpp.obj -o magic8ball_server.exe -Wl,--out-implib,server\libmagic8ball_server.dll.a -Wl,--major-image-version,0,--minor-image-version,0  C:/Qt/6.9.1/mingw_64/lib/libQt6Core.a  vcpkg_installed/x64-windows/debug/lib/grpc++.lib  -lmpr  -luserenv  vcpkg_installed/x64-windows/debug/lib/libprotobufd.lib  vcpkg_installed/x64-windows/debug/lib/grpc.lib  vcpkg_installed/x64-windows/debug/lib/upb_json_lib.lib  vcpkg_installed/x64-windows/debug/lib/upb_textformat_lib.lib  vcpkg_installed/x64-windows/debug/lib/upb_mini_descriptor_lib.lib  vcpkg_installed/x64-windows/debug/lib/upb_wire_lib.lib  vcpkg_installed/x64-windows/debug/lib/utf8_range.lib  vcpkg_installed/x64-windows/debug/lib/upb_message_lib.lib  vcpkg_installed/x64-windows/debug/lib/upb_base_lib.lib  vcpkg_installed/x64-windows/debug/lib/upb_mem_lib.lib  vcpkg_installed/x64-windows/debug/lib/re2.lib  vcpkg_installed/x64-windows/debug/lib/zlibd.lib  vcpkg_installed/x64-windows/debug/lib/cares.lib  -ladvapi32  -liphlpapi  vcpkg_installed/x64-windows/debug/lib/gpr.lib  vcpkg_installed/x64-windows/debug/lib/absl_flags_internal.lib  vcpkg_installed/x64-windows/debug/lib/absl_flags_reflection.lib  vcpkg_installed/x64-windows/debug/lib/absl_flags_config.lib  vcpkg_installed/x64-windows/debug/lib/absl_flags_program_name.lib  vcpkg_installed/x64-windows/debug/lib/absl_flags_private_handle_accessor.lib  vcpkg_installed/x64-windows/debug/lib/absl_flags_commandlineflag.lib  vcpkg_installed/x64-windows/debug/lib/absl_flags_commandlineflag_internal.lib  vcpkg_installed/x64-windows/debug/lib/absl_flags_marshalling.lib  vcpkg_installed/x64-windows/debug/lib/abseil_dll.lib  -ignore:4221  vcpkg_installed/x64-windows/debug/lib/libssl.lib  vcpkg_installed/x64-windows/debug/lib/libcrypto.lib  vcpkg_installed/x64-windows/debug/lib/address_sorting.lib  -lwsock32  -lws2_32  -lcrypt32  -lgdi32  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && C:\WINDOWS\system32\cmd.exe /C "cd /D C:\Qt\Examples\Qt-6.9.1\grpc\magic8ball\build\Desktop_Qt_6_9_1_MinGW_64_bit-Debug\server && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file C:/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/magic8ball_server.exe -installedDir C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug/vcpkg_installed/x64-windows/debug/bin -OutVariable out""
          g++.exe: error: unrecognized command-line option '-ignore:4221'
          [23/55 1.4/sec] Building CXX object CMakeFiles/magic8ball_plugin.dir/exampleservice_client.grpc.qpb.cpp.obj
          [24/55 1.5/sec] Building CXX object CMakeFiles/magic8ball_plugin.dir/magic8ball_plugin_autogen/mocs_compilation.cpp.obj
          [25/55 1.5/sec] Building CXX object CMakeFiles/magic8ball_plugin.dir/qmlexampleservice_client.grpc.qpb.cpp.obj
          [26/55 1.5/sec] Building CXX object CMakeFiles/magic8ball_plugin.dir/exampleservice.qpb.cpp.obj
          [27/55 1.5/sec] Building CXX object CMakeFiles/magic8ball_plugin.dir/magic8ball_plugin_qmltyperegistrations.cpp.obj
          ninja: build stopped: subcommand failed.
          00:13:18: The command "C:\Qt\Tools\CMake_64\bin\cmake.exe --build C:/Qt/Examples/Qt-6.9.1/grpc/magic8ball/build/Desktop_Qt_6_9_1_MinGW_64_bit-Debug --target all" terminated with exit code 1.
          00:13:18: Error while building/deploying project Magic8Ball (kit: Desktop Qt 6.9.1 MinGW 64-bit)
          00:13:18: When executing step "Build"
          00:13:18: Elapsed time: 00:18.
          
          

          do i need to configure any environment variables.
          I am trying to build using qt creator only.

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

            Based on the cmake output, it seems that Visual Studio should be used for this example:

            magic8ball_server uses reference grpc++ library that doesn't officially
            [cmake]   support MinGW.  Please use the MSVC compiler to build this example.  The
            [cmake]   correct work is not guaranteed otherwise.
            [cmake] 
            

            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
            • G Offline
              G Offline
              greed_14
              wrote on last edited by
              #5

              Should i use MSVC kit instead of mingw or i should compile it using visual studio.

              on ubuntu after installing protobuf and grpc i was able to compile it but not able to do the same on windows

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

                You need the MSVC compiler for the MSVC kit but not the full Visual Studio installation.

                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
                • G Offline
                  G Offline
                  greed_14
                  wrote on last edited by
                  #7

                  Screenshot 2025-08-08 005110.png

                  I have these MSVC compilers installed.

                  JonBJ 1 Reply Last reply
                  0
                  • G greed_14

                    Screenshot 2025-08-08 005110.png

                    I have these MSVC compilers installed.

                    JonBJ Online
                    JonBJ Online
                    JonB
                    wrote on last edited by
                    #8

                    @greed_14 So, not that I know much about this, but did you try using the one you show selected?

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      greed_14
                      wrote on last edited by
                      #9

                      Hi,

                      Thanks for your response.

                      I was able to get it working by using the MSVC kit.

                      Here are the steps I followed, in case anyone else encounters the same issue:

                      1. Installed MSVC 2022 C++ for Desktop, which allowed Qt Creator to auto-detect the MSVC compilers.

                      2. Cloned and bootstrapped vcpkg, then installed the required package:

                      git clone https://github.com/microsoft/vcpkg.git
                      cd vcpkg
                      .\bootstrap-vcpkg.bat
                      
                      .\vcpkg.exe install grpc --triplet x64-windows
                      
                      
                      1. Selected the amd64 compiler in Qt Creator.

                      2. Updated my CMake configuration as follows:

                      -DCMAKE_TOOLCHAIN_FILE:UNINITIALIZED=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
                      -DVCPKG_TARGET_TRIPLET:UNINITIALIZED=x64-windows
                      -DQT_USE_VCPKG:UNINITIALIZED=ON
                      

                      both server and client binaries were present in the same build directory.

                      Regards,
                      Adnan

                      1 Reply Last reply
                      1
                      • G greed_14 has marked this topic as solved on

                      • Login

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