How to use rust with gcc on Windows?

โš“ Rust    ๐Ÿ“… 2026-03-07    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 1      

surdeus

I am still fairly new to programming in rust and might be missing something obvious to crustaceans. I mainly work on Linux, but I want my project to support Windows, too. To make my life easier, I am not going for a Linuxโ†’Windows cross-compile. Instead, I set-up a virtual machine, installed Windows 11 and rustup.

Now when I select the stable-x86_64-pc-windows-gnu toolchain and cargo build --target i686-pc-windows-gnu my project, a lot of dependencies are downloaded for building, one of them being "boring". To my surprise, rust demands a C compiler to build "boring", so I quickly installed GCC via MSYS2 and added its gcc to the PATH. However, the build still fails with this error message:

error: failed to run custom build command for `boring-sys v5.0.2 (https://github.com/signalapp/boring?tag=signal-v5.0.2#2c157897)`
running: "cmake" "rust_079a6\\i686-pc-windows-gnu\\release\\build\\boring-sys-f9aaa791cc3ff20d\\out\\boringssl" "-B" "rust_079a6\\i686-pc-windows-gnu\\release\\build\\boring-sys-f9aaa791cc3ff20d\\out\\build" "-G" "MSYS Makefiles" "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL" "-DCMAKE_CROSSCOMPILING=true" "-DCMAKE_C_COMPILER_TARGET=i686-pc-windows-gnu" "-DCMAKE_CXX_COMPILER_TARGET=i686-pc-windows-gnu" "-DCMAKE_ASM_COMPILER_TARGET=i686-pc-windows-gnu" "-DOPENSSL_NO_ASM=YES" "-DCMAKE_SYSTEM_NAME=Windows" "-DCMAKE_SYSTEM_PROCESSOR=X86" "-DCMAKE_INSTALL_PREFIX=rust_079a6\\i686-pc-windows-gnu\\release\\build\\boring-sys-f9aaa791cc3ff20d\\out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -m32 -w" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -m32 -w" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -m32 -w" "-DCMAKE_BUILD_TYPE=Release"
CMake Error at CMakeLists.txt:36 (enable_language): The CMAKE_C_COMPILER: cl is not a full path and was not found in the PATH.

As far as I know, "cl.exe" is the Microsoft C Compiler, which is, indeed, not installed. Do I really need the Microsoft tools, even when going for a i686-pc-windows-gnu build?

Kind Regards
Hermann

1 post - 1 participant

Read full topic

๐Ÿท๏ธ Rust_feed