Cannot cross compile from linux to windows
After the Rust code is integrated, I cannot build librsvg for Windows by using mingw-w64 on GNU/Linux.
Past librsvg & most dependent libraries can build win32 binaries by the following steps:
- Install mingw-w64
- e.g.) On Ubuntu:
$ sudo apt install mingw-w64
- Run configure script with
--host
option and some environment variables:
CFLAGS="-I/path/to/win32/include" \
CXXFLAGS="-I/path/to/win32/include" \
LDFLAGS=-L/path/to/win32/lib \
PKG_CONFIG_PATH=/path/to/win32/lib/pkgconfig \
$./configure --prefix=/path/to/win32 --target=x86_64-w64-mingw32
- Build
$ make
$ make install
But when I tried to build librsvg-2.42.3 with the above steps, I got the following error:
cargo build --target=x86_64-w64-mingw32 --release
error: failed to run `rustc` to learn about target-specific information
Caused by:
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --target x86_64-w64-mingw32 --crate-type bin --crate-type proc-macro --crate-type rlib --crate-type staticlib` (exit code: 101)
--- stderr
error: Error loading target specification: Could not find specification for target "x86_64-w64-mingw32"
|
= help: Use `--print target-list` for a list of built-in targets
I installed Rust by rustup:
$ curl https://sh.rustup.rs -sSf | sh
$ rustup target add x86_64-pc-windows-gnu