Hugal31 / yara-rust

Rust bindings for VirusTotal/Yara
Apache License 2.0
70 stars 30 forks source link

Build Error on Windows when using yara crate #121

Closed EsharkySignalZero closed 11 months ago

EsharkySignalZero commented 1 year ago

While using the yara crate in a rust program on windows and only testing the example code used in the repo im getting the following error while building. Can someone pls guide me about the proper build process in Windows for this crate

error: failed to run custom build command for `yara-sys v0.20.0`

Caused by:
  process didn't exit successfully: `C:\Users\randh\Rust-Scanner\target\debug\build\yara-sys-15d8fae16b2c3f3e\build-script-build` (exit code: 101)
  --- stdout
  cargo:rustc-link-lib=dylib=yara
  cargo:rerun-if-env-changed=YARA_LIBRARY_PATH
  cargo:rerun-if-env-changed=YARA_LIBRARY_PATH_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=YARA_LIBRARY_PATH_x86_64_pc_windows_msvc

  --- stderr
  wrapper.h:1:10: fatal error: 'yara.h' file not found
  thread 'main' panicked at 'Unable to generate bindings: ClangDiagnostic("wrapper.h:1:10: fatal error: 'yara.h' file not found\n")', C:\Users\randh\.cargo\registry\src\index.crates.io-6f17d22bba15001f\yara-sys-0.20.0\build.rs:427:43
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrac
ikrivosheev commented 1 year ago

@EsharkySignalZero hello! Can you show your Cargo.toml file?

Benji377 commented 11 months ago

Hello @ikrivosheev, I am having the exact same issue. Here is my Cargo.toml file:

[package]
name = "experimenting"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
yara = "0.20.0"
Hugal31 commented 11 months ago

Hello,

The steps to build this on Windows and make it link correctly with Yara are written in yara-sys README.

In a nutshell, there is two possible use cases:

Which workflow did you tried?

Benji377 commented 11 months ago

Oh my mistake, I forgot to add the vendored feature as you can see in the Cargo.toml file I shared. Thank you very much!