informationsea / xlsxwriter-rs

Excel file writer for Rust
https://crates.io/crates/xlsxwriter
Apache License 2.0
265 stars 44 forks source link

What's the prefered way to use this crate under windows #24

Closed smuel-adm closed 2 years ago

smuel-adm commented 2 years ago

What is the prefered way to use this crate in a custom project, under windows?

I've tryed latest rust MSVC version this way:

First setup and checked latest stable rust...

rustup override set stable-x86_64-pc-windows-msvc
rustc -Vv

Output rust check:

rustc 1.56.1 (59eed8a2a 2021-11-01)
binary: rustc
commit-hash: 59eed8a2aac0230a8b53e89d4e99d55912ba6b35
commit-date: 2021-11-01
host: x86_64-pc-windows-msvc
release: 1.56.1
LLVM version: 13.0.0

Then setup a custom crate the usual way:

cargo new --bin test-xmlxwriter
cd .\test-xmlxwriter\
Add-Content .\Cargo.toml 'xlsxwriter-rs ="*"'
cargo build

This results in that error:

error: failed to run custom build command for `xlsxwriter-rs v0.1.0`

Caused by:
  process didn't exit successfully: `C:\temp\test-xmlxwriter\target\debug\build\xlsxwriter-rs-962004a654e6acf4\build-script-build` (exit code: 101)
  --- stdout
  cargo:rustc-link-lib=xlsxwriter

  --- stderr
  wrapper.h:1:10: fatal error: 'xlsxwriter.h' file not found
  wrapper.h:1:10: fatal error: 'xlsxwriter.h' file not found, err: true
  thread 'main' panicked at 'Unable to generate xlsxwriter bindings: ()', C:\Users\smuel\.cargo\registry\src\github.com-1ecc6299db9ec823\xlsxwriter-rs-0.1.0\build.rs:12:6
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

If build the xlsxwriter-rs crate self all went fine.

git clone https://github.com/informationsea/xlsxwriter-rs.git
cd .\xlsxwriter-rs\
git submodule update --init --recursive
cargo build

What is missing in the above commands for a custom crate?

smuel-adm commented 2 years ago

Ok I solved it. Looks the latest version on crates.io is a little outdated. Using the git master branch solves all issues.

Cargo.toml

[dependencies]
xlsxwriter = { git = "https://github.com/informationsea/xlsxwriter-rs.git" }