Hugal31 / yara-rust

Rust bindings for VirusTotal/Yara
Apache License 2.0
77 stars 28 forks source link

Compilation Error #15

Closed muteb closed 3 years ago

muteb commented 3 years ago

Hi,

Thank you very much for creating this awesome crate. I add the yara crate to the toml and compile it but I faced this error.

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

Caused by:
  process didn't exit successfully: `C:\Users\*****\Desktop\yara-rust\rsyara-scanner\target\debug\build\yara-sys-ab4856629aaf30fc\build-script-build` (exit code: 101)
  --- stdout
  cargo:rustc-link-lib=dylib=yara

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

Is there a way to solve this issue!

Thanks.

Hugal31 commented 3 years ago

Hi,

Thanks for submitting this issue. The problem is probably the location of your yara.h file.

If this doesn't work, maybe use the vendored feature of yara-rust.

muteb commented 3 years ago

Hi, Thank youv ery much . I added the dir to the environment and it found the yara.h file, however, I run into another issue:

Compiling yara-sys v0.4.2 (C:\Users\****\Desktop\yara-rust\yara-rust\yara-sys)
error[E0412]: cannot find type `YR_ARENA` in this scope
    --> C:\Users\****\Desktop\yara-rust\yara-rust\target\debug\build\yara-sys-6a2f9b3efd5af1e9\out/bindings.rs:4807:21
     |
4807 |     pub arena: *mut YR_ARENA,
     |                     ^^^^^^^^ not found in this scope

error[E0412]: cannot find type `YR_ARENA` in this scope
    --> C:\Users\****\Desktop\yara-rust\yara-rust\target\debug\build\yara-sys-6a2f9b3efd5af1e9\out/bindings.rs:5875:21
     |
5875 |         arena: *mut YR_ARENA,
     |                     ^^^^^^^^ not found in this scope

error[E0609]: no field `__bindgen_anon_1` on type `&YR_MATCHES`
  --> yara-sys\src\lib.rs:40:23
   |
40 |         unsafe { self.__bindgen_anon_1.head }
   |                       ^^^^^^^^^^^^^^^^ unknown field
   |
   = note: available fields are: `head`, `tail`, `count`

error[E0609]: no field `__bindgen_anon_2` on type `&YR_MATCHES`
  --> yara-sys\src\lib.rs:44:23
   |
44 |         unsafe { self.__bindgen_anon_2.tail }
   |                       ^^^^^^^^^^^^^^^^ unknown field
   |
   = note: available fields are: `head`, `tail`, `count`

error[E0609]: no field `identifier` on type `YR_STRING__bindgen_ty_1`
  --> yara-sys\src\lib.rs:88:40
   |
88 |         unsafe { self.__bindgen_anon_1.identifier }
   |                                        ^^^^^^^^^^ unknown field
   |
   = note: available fields are: `string`, `string_`, `_bindgen_union_align`

error[E0609]: no field `string` on type `YR_STRING__bindgen_ty_2`
  --> yara-sys\src\lib.rs:92:40
   |
92 |         unsafe { self.__bindgen_anon_2.string as _ }
   |                                        ^^^^^^ unknown field
   |
   = note: available fields are: `chained_to`, `chained_to_`, `_bindgen_union_align`

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0412, E0609.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `yara-sys`

Do I need to use certain version of LLM or yaralib?

Thanks alot.

Hugal31 commented 3 years ago

I think you may be using yara v4.0. For now, this library only supports yara up to 3.11. You may use the vendored feature to automatically download and build Yara 3.11.

Le ven. 19 mars 2021 à 11:50, muteb alqahtani @.***> a écrit :

Hi, Thank youv ery much . I added the dir to the environment and it found the yara.h file, however, I run into another issue:

Compiling yara-sys v0.4.2 (C:\Users**\Desktop\yara-rust\yara-rust\yara-sys) error[E0412]: cannot find type YR_ARENA in this scope --> C:\Users**\Desktop\yara-rust\yara-rust\target\debug\build\yara-sys-6a2f9b3efd5af1e9\out/bindings.rs:4807:21 | 4807 | pub arena: *mut YR_ARENA, | ^^^^^^^^ not found in this scope

error[E0412]: cannot find type YR_ARENA in this scope --> C:\Users***\Desktop\yara-rust\yara-rust\target\debug\build\yara-sys-6a2f9b3efd5af1e9\out/bindings.rs:5875:21 | 5875 | arena: mut YR_ARENA, | ^^^^^^^^ not found in this scope

error[E0609]: no field __bindgen_anon_1 on type &YR_MATCHES --> yara-sys\src\lib.rs:40:23 40 unsafe { self.__bindgen_anon_1.head } ^^^^^^^^^^^^^^^^ unknown field

= note: available fields are: head, tail, count

error[E0609]: no field __bindgen_anon_2 on type &YR_MATCHES --> yara-sys\src\lib.rs:44:23 44 unsafe { self.__bindgen_anon_2.tail } ^^^^^^^^^^^^^^^^ unknown field

= note: available fields are: head, tail, count

error[E0609]: no field identifier on type YR_STRING__bindgen_ty_1 --> yara-sys\src\lib.rs:88:40 88 unsafe { self.__bindgen_anon_1.identifier } ^^^^^^^^^^ unknown field

= note: available fields are: string, string_, _bindgen_union_align

error[E0609]: no field string on type YR_STRING__bindgen_ty_2 --> yara-sys\src\lib.rs:92:40 92 unsafe { self.__bindgen_anon2.string as } ^^^^^^ unknown field

= note: available fields are: chained_to, chained_to_, _bindgen_union_align

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0412, E0609. For more information about an error, try rustc --explain E0412. error: could not compile yara-sys

Do I need to use certain version of LLM or yaralib?

Thanks alot.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Hugal31/yara-rust/issues/15#issuecomment-802735711, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFGRU4X5U3TJY5RP3IO4UDTEMT6XANCNFSM4ZNXIAJQ .

muteb commented 3 years ago

thank you very vary much. I managed to use yara3.11 and it works like a charm.

muteb commented 3 years ago

Hi Hugel31,

when I do the cargo build, it works fine without any problem but when I try the cargo test, it return "error: linking with link.exe failed: exit code: 1181" although I have vs C++ tools installed and had compiled other project before. I'm wondering what chaintool do you use "stable-i686-pc-windows-msvc" or "stable-x86_64-pc-windows-gnu"?

Thanks,

Hugal31 commented 3 years ago

Mmmh, I wish link.exe was more verbose. I am not familiar with build on Windows, but I assume it didn't find the library. As you did with the header, locate yara.dll (or yara.lib), and set the YARA_LIBRARY_PATH environment variable directly to the file (or is it to the directory ?). Run cargo clean -p yara-sys before that. Sorry if that doesn't work, but I rarely code on Windows. Alternatively, try the vendored feature of yara-rust.

muteb commented 3 years ago

worked like a charm. I set the YARA_LIBRARY_PATH to point to the yara.lib and compile it again and it workd fine.. thanks alot.