Is that meant to be done automatically by Cargo, or do I need to add Rust’s GCC to the PATH manually? I tried the later but it still didn’t work (different error message)
Full error message:
$ cargo build
Compiling url v1.2.3
Compiling miniz-sys v0.1.7
Compiling fs2 v0.3.0
Compiling term v0.4.4
Build failed, waiting for other jobs to finish...
error: failed to run custom build command for `miniz-sys v0.1.7`
process didn't exit successfully: `D:\devel\rust\cargo0\target\debug\build\miniz-sys-60c8d67696f63a43\build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-pc-windows-gnu")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
TARGET = Some("x86_64-pc-windows-gnu")
debug=true opt-level=0
HOST = Some("x86_64-pc-windows-gnu")
TARGET = Some("x86_64-pc-windows-gnu")
TARGET = Some("x86_64-pc-windows-gnu")
HOST = Some("x86_64-pc-windows-gnu")
CC_x86_64-pc-windows-gnu = None
CC_x86_64_pc_windows_gnu = None
HOST_CC = None
CC = None
TARGET = Some("x86_64-pc-windows-gnu")
HOST = Some("x86_64-pc-windows-gnu")
CFLAGS_x86_64-pc-windows-gnu = None
CFLAGS_x86_64_pc_windows_gnu = None
HOST_CFLAGS = None
CFLAGS = None
running: "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-m64" "-o" "D:\\devel\\rust\\cargo0\\target\\debug\\build\\miniz-sys-60c8d67696f63a43\\out\\miniz.o" "-c" "miniz.c"
failed to execute command: The system cannot find the file specified. (os error 2)
Is `gcc.exe` not installed? (see https://github.com/alexcrichton/gcc-rs#compile-time-requirements for help)
--- stderr
thread 'main' panicked at 'explicit panic', C:\Users\bruno\.cargo\registry\src\github.com-1ecc6299db9ec823\gcc-0.3.38\src\lib.rs:958
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Oh the compiler uses the bundled gcc for linking. For compiling something like Cargo you’ll need a full-blown C compiler, in which case you’ll need to install externally through some other source. The README in the rust-lang/rust project can help with this.
Looks like you to link some libraries in your LIBRARY_PATH as well. According to cargo's README it looks like they really assume a Linux target for building and they don’t list all of the libraries needed so it could be difficult to build it from source without some more documentation from the cargo developers.
I’ve worked with other Rust libraries (like rust-sdl2) that do spell out how to build and link in the needed dependancies on Windows. You could open an issue and see if anyone is willing to document this.
Edit: Check out: cargo’s appveyor.yml file which builds cargo on a Windows VM for hints on how to build on Windows.
So I’m looking at this again, but I’m still stuck. I do have a libz.a, it is in C:\msys64\mingw64\lib though. Most other libs are in C:\msys64\mingw64\x86_64-w64-mingw32\lib, and the Cargo build seems to find those okay.
I’ve tried a simple C Hello World on the MSys2 shell: gcc main.c -lz and that works. So I do have the z lib and it can be linked fine - that seems to indicate the problem might be in the Cargo build?
Ok, I re-installed Msys, Rust installation, redid settings, I think I fixed that. No longer have the “cannot find -lz” problem, but now stuck on the strtok_r problem: https://github.com/jonathandturner/rls/issues/151