How can I compile my program to a windows executable

I have a C++ program that uses protobuf and asio, which compiles fine under Linux using g++. I am wondering how I could go about making a new preset which allows me to compile this program into a windows executable.

I have tried using mingw compiler, but it seems I do not understand how to use it properly.

This is my CmakePresets.json

{
    "version": 8,
    "configurePresets": [
        {
            "name": "debug",
            "displayName": "Debug",
            "description": "Using compiler: CXX = /usr/bin/g++",
            "binaryDir": "${sourceDir}/out/build/${presetName}",
            "cacheVariables": {
                "CMAKE_CXX_COMPILER": "/usr/bin/g++",
                "CMAKE_BUILD_TYPE": "Debug"
            }
        },
        {
            "name": "windows-debug",
            "displayName": "Windows Debug",
            "description": "Using compiler: CXX = /usr/bin/x86_64-w64-mingw32-g++",
            "binaryDir": "${sourceDir}/out/build/${presetName}",
            "cacheVariables": {
                "CMAKE_SYSTEM_NAME": "Windows",
                "CMAKE_CXX_COMPILER": "/usr/bin/x86_64-w64-mingw32-g++",
                "CMAKE_BUILD_TYPE": "Debug"
            }
        }
    ],
    "buildPresets": [
        {
            "name": "debug",
            "configurePreset": "debug"
        },
        {
            "name": "windows-debug",
            "configurePreset": "windows-debug"
        }
    ]
}

CMake generation fails because it can’t find “ZLIB::ZLIB”:

[main] Configuring project: dark-proxy 
[proc] Executing command: /usr/bin/cmake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_COMPILER=/usr/bin/x86_64-w64-mingw32-g++ -DCMAKE_BUILD_TYPE=Debug -S/home/burger/Desktop/dark-proxy -B/home/burger/Desktop/dark-proxy/out/build/windows-debug
[cmake] -- Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.3")
[cmake] CMake Warning at /usr/local/lib/cmake/protobuf/protobuf-config.cmake:9 (find_package):
[cmake]   Found package configuration file:
[cmake] 
[cmake]     /usr/local/lib/cmake/absl/abslConfig.cmake
[cmake] 
[cmake]   but it set absl_FOUND to FALSE so package "absl" is considered to be NOT
[cmake]   FOUND.  Reason given by package:
[cmake] 
[cmake]   The following imported targets are referenced, but are missing:
[cmake]   protobuf::gmock
[cmake] 
[cmake] Call Stack (most recent call first):
[cmake]   protos/CMakeLists.txt:1 (find_package)
[cmake] 
[cmake] 
[cmake] -- Found Protobuf package with version : 29.0.0
[cmake] -- Configuring done (0.0s)
[cmake] CMake Error at /usr/local/lib/cmake/protobuf/protobuf-targets.cmake:70 (set_target_properties):
[cmake]   The link interface of target "protobuf::libprotobuf" contains:
[cmake] 
[cmake]     ZLIB::ZLIB
[cmake] 
[cmake]   but the target was not found.  Possible reasons include:
[cmake] 
[cmake]     * There is a typo in the target name.
[cmake]     * A find_package call is missing for an IMPORTED target.
[cmake]     * An ALIAS target is missing.
[cmake] 
[cmake] Call Stack (most recent call first):
[cmake]   /usr/local/lib/cmake/protobuf/protobuf-config.cmake:16 (include)
[cmake]   protos/CMakeLists.txt:1 (find_package)
[cmake] 
[cmake] 
[cmake] -- Generating done (0.0s)
[cmake] CMake Generate step failed.  Build files cannot be regenerated correctly.
[proc] The command: /usr/bin/cmake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_COMPILER=/usr/bin/x86_64-w64-mingw32-g++ -DCMAKE_BUILD_TYPE=Debug -S/home/burger/Desktop/dark-proxy -B/home/burger/Desktop/dark-proxy/out/build/windows-debug exited with code: 1

This is what the Cmake generation looks like when I use g++:

[main] Configuring project: dark-proxy 
[proc] Executing command: /usr/bin/cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_BUILD_TYPE=Debug -S/home/burger/Desktop/dark-proxy -B/home/burger/Desktop/dark-proxy/out/build/debug
[cmake] CMake Warning at /usr/local/lib/cmake/protobuf/protobuf-config.cmake:9 (find_package):
[cmake]   Found package configuration file:
[cmake] 
[cmake]     /usr/local/lib/cmake/absl/abslConfig.cmake
[cmake] 
[cmake]   but it set absl_FOUND to FALSE so package "absl" is considered to be NOT
[cmake]   FOUND.  Reason given by package:
[cmake] 
[cmake]   The following imported targets are referenced, but are missing:
[cmake]   protobuf::gmock
[cmake] 
[cmake] Call Stack (most recent call first):
[cmake]   protos/CMakeLists.txt:1 (find_package)
[cmake] 
[cmake] 
[cmake] -- Found Protobuf package with version : 29.0.0
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: /home/burger/Desktop/dark-proxy/out/build/debug

How do I use mingw to compile my project in the same way that g++ works to get a windows executable?

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật