Hi, I am trying to configure Rust in Windows to enable cross-compilation of generic Rust binaries (think Hello World) for Linux targets. I installed the x86_64-unknown-linux-gnu target with rustup, but when I try to build my application, I get an error about a missing cc
program. Well, cc
isn't normally available in Windows, that would be more like cl
from Visual Studio.
$ cargo build --target x86_64-unknown-linux-gnu
Compiling hello v0.0.1 (file:///C:/Users/a_pen/go/src/github.com/mcandre/toys/rust/hello)
error: could not exec the linker `cc`: The system cannot find the file specified. (os error 2)
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib" "C:\\Users\\a_pen\\go\\src\\github.com\\mcandre\\toys\\rust\\hello\\target\\x86_64-unknown-linux-gnu\\debug\\deps\\hello-b48813c72b5be0f1.hello0.rcgu.o" "C:\\Users\\a_pen\\go\\src\\github.com\\mcandre\\toys\\rust\\hello\\target\\x86_64-unknown-linux-gnu\\debug\\deps\\hello-b48813c72b5be0f1.hello1.rcgu.o" "-o" "C:\\Users\\a_pen\\go\\src\\github.com\\mcandre\\toys\\rust\\hello\\target\\x86_64-unknown-linux-gnu\\debug\\deps\\hello-b48813c72b5be0f1" "C:\\Users\\a_pen\\go\\src\\github.com\\mcandre\\toys\\rust\\hello\\target\\x86_64-unknown-linux-gnu\\debug\\deps\\hello-b48813c72b5be0f1.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "C:\\Users\\a_pen\\go\\src\\github.com\\mcandre\\toys\\rust\\hello\\target\\x86_64-unknown-linux-gnu\\debug\\deps" "-L" "C:\\Users\\a_pen\\go\\src\\github.com\\mcandre\\toys\\rust\\hello\\target\\debug\\deps" "-L" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib" "-Wl,-Bstatic" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib\\libstd-58a9e2944951d97f.rlib" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib\\libpanic_unwind-167b5e977a2ab35c.rlib" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib\\libunwind-b8892ba833aa6677.rlib" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib\\liballoc_system-17235785be0fea01.rlib" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib\\liblibc-2e9b8cf09e3563de.rlib" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib\\liballoc-d7195d5e94bc6586.rlib" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib\\libstd_unicode-963f18f265d9b8d3.rlib" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib\\libcore-48934815da5d2bfb.rlib" "C:\\Users\\a_pen\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-unknown-linux-gnu\\lib\\libcompiler_builtins-a6b6fad6cc543169.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util"
error: aborting due to previous error
error: Could not compile `hello`.
Does cross-compilation require a cc
compiler from Cygwin, or is there some other way to fix the Rust system so that it can successfully build Linux binaries from Windows? I'd prefer to perform this compilation natively on the host, without fussing with dual booting Linux or setting up virtual machines.