RustAudio / deepspeech-rs

Rust bindings for the deepspeech library
Other
296 stars 24 forks source link

cannot open input file 'deepspeech.lib' / Windows 10 #25

Open LeSplooch opened 4 years ago

LeSplooch commented 4 years ago

Hello. After following the steps in your "Quickstart" section of the README.md, I tried compiling a crate using deepspeech-rs v0.6.1 on Windows 10, and I'm having the following error :

LINK : fatal error LNK1181: cannot open input file 'deepspeech.lib'

It looks like the compiler can't find a file but I don't know how to get it.

I'm really sorry if it's not the right place to talk about this but I can't find help anywhere else.

est31 commented 4 years ago

Have you added the directory with deepspeech.lib to your path?

LeSplooch commented 4 years ago

I didn't get any file called deepspeech.lib with the tar.gz file you mentioned on your README and the native_client version for Windows, and the native_client is added to my path.

est31 commented 4 years ago

Hmm I see, that's a valid question. There is a .lib file in the windows native client but it's called differently.

LeSplooch commented 4 years ago

Indeed, there is a file called libdeepspeech.so.if.lib.

est31 commented 4 years ago

@LeSplooch if you clone this repo, and change the "deepspeech" in sys/build.rs to deepspeech.so, does it work then?

LeSplooch commented 4 years ago

@LeSplooch if you clone this repo, and change the "deepspeech" in sys/build.rs to deepspeech.so, does it work then?

Oh sorry I just saw your post, I'll try this asap and let you know about the result.

est31 commented 4 years ago

@LeSplooch don't worry I got the idea just now and was already afraid you dismissed deepspeech completely. With https://github.com/rust-lang/rust/issues/58713 we might make the usage of .lib files obsolete.

Also if my suggestion doesnt work, try changing it to deepspeech.so.if.

LeSplooch commented 4 years ago

I was about to do it but I've never worked with folder crates yet, so I'd need a little help in order to import that into my code. I just cargo add everything most of the time or link the git in Cargo.toml.

est31 commented 4 years ago

@LeSplooch the docs for path dependencies are here: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-path-dependencies

You could clone deepspeech-rs and then point to the local clone via path instead of the crates.io version.

LeSplooch commented 4 years ago

I'm really sorry for the delayed answer. So deepspeech-rs is cloned and linked in Cargo.toml and ./deepspeech-rs/sys/build.rs has been modified to this :

fn main() {
    println!("cargo:rustc-link-lib=deepspeech.so");
}

But now I have a problem : apparently, Model.enable_decoder_with_lm() doesn't exist anymore, and I don't know what to replace it with.

est31 commented 4 years ago

It's not needed any more, see 987669529c5b1aea8f5a761349a15a0dac2bd50b

LeSplooch commented 4 years ago

I still have a link.exe fatal error message with both deepspeech.so and deepspeech.so.if.

= note: LINK : fatal error LNK1181: cannot open input file 'deepspeech.so.lib' = note: LINK : fatal error LNK1181: cannot open input file 'deepspeech.so.if.lib'

est31 commented 4 years ago

That issue is because the linker can't find those files. But they exist, you just have to tell the directory the downloaded precompiled library lies inside. Have you added it to the PATH environment variable?

LeSplooch commented 4 years ago

The absolute path to native_client is among my Path env vars.

gamma-delta commented 4 years ago

I'm also having this problem.

gamma-delta commented 4 years ago

I guess I should add something a little more helpful...

I've changed build.rs locally to exactly the name of the file I downloaded:

#[cfg(target_os = "windows")]
fn main() {
    println!("cargo:rustc-link-lib=libdeepspeech.so.if");
}

It still doesn't work, even though the folder is in my path. where libdeepspeech.so.if.lib succeeds (I'm using Cygwin).

EDIT: libdeepspeech.so like you suggested also doesn't work.

gamma-delta commented 4 years ago

I got it!

My local copy of build.rs now looks like this:

// It's bugged on windows >:(
#[cfg(target_os = "windows")]
fn main() {
    println!(r"cargo:rustc-link-search=C:\deepspeech");
    println!("cargo:rustc-link-lib=libdeepspeech.so.if");
}

#[cfg(not(target_os = "windows"))]
fn main() {
    println!("cargo:rustc-link-lib=deepspeech");
}

I also have put the folder I downloaded where I marked above. (I had it deeper in my file tree, but my username has a space in it and rustc was having a hard time with it.) I also added that folder to PATH.

Yay! Hope this helps @LeSplooch!

est31 commented 4 years ago

@gamma-delta Awesome! Can you put this into a PR?

gamma-delta commented 4 years ago

Maybe! I'm not the best at Github.

Probably what I'll do is set it up with an environment variable, and include in the install instructions to set it to wherever you put the files. Then build.rs just queries the variable.

retep998 commented 4 years ago

For the record, if you want to tell the linker on Windows where you have libraries installed, you need to modify LIB, not PATH. LIB is used to find libraries (foo.lib) at link time, PATH is used to find binaries (foo.dll/foo.exe) at run time.

LeSplooch commented 4 years ago

@retep998 If I understand you correctly, I should create a value containing a comma seperated array with the path to the folder where my deepspeech.lib file is, and assign it to a new variable called LIB, is that it? I have no LIB variable at the moment.

LeSplooch commented 4 years ago

I tried it and now I have another error, but I think it's a good sign, it looks like the libraries have been found but it can't handle them for some reason (I'm not familiar with linker errors).

Here is the output :

  = note: libdeepspeech-596af0fd2763f984.rlib(deepspeech-596af0fd2763f984.deepspeech.6i45m1o7-cgu.2.rcgu.o) : error LNK2019: unresolved external symbol DS_EnableExternalScorer referenced in function _ZN10deepspeech5Model22enable_external_scorer17h9fc6471303cc31e3E
          libdeepspeech-596af0fd2763f984.rlib(deepspeech-596af0fd2763f984.deepspeech.6i45m1o7-cgu.2.rcgu.o) : error LNK2019: unresolved external symbol DS_DisableExternalScorer referenced in function _ZN10deepspeech5Model23disable_external_scorer17h3721a9ad438e6571E
          libdeepspeech-596af0fd2763f984.rlib(deepspeech-596af0fd2763f984.deepspeech.6i45m1o7-cgu.2.rcgu.o) : error LNK2019: unresolved external symbol DS_GetModelBeamWidth referenced in function 
_ZN10deepspeech5Model20get_model_beam_width17ha127ef1639900027E
          libdeepspeech-596af0fd2763f984.rlib(deepspeech-596af0fd2763f984.deepspeech.6i45m1o7-cgu.2.rcgu.o) : error LNK2019: unresolved external symbol DS_SetModelBeamWidth referenced in function 
_ZN10deepspeech5Model20set_model_beam_width17h3cfba3f016bf445fE
          libdeepspeech-596af0fd2763f984.rlib(deepspeech-596af0fd2763f984.deepspeech.6i45m1o7-cgu.2.rcgu.o) : error LNK2019: unresolved external symbol DS_SetScorerAlphaBeta referenced in function _ZN10deepspeech5Model21set_scorer_alpha_beta17hf22408dd472bc89eE
          libdeepspeech-596af0fd2763f984.rlib(deepspeech-596af0fd2763f984.deepspeech.6i45m1o7-cgu.2.rcgu.o) : error LNK2019: unresolved external symbol DS_Version referenced in function _ZN10deepspeech18deepspeech_version17ha05bd2d6a0180a9cE
          F:\Rust Test\cpal_test\target\release\deps\cpal_test.exe : fatal error LNK1120: 6 unresolved externals

error: aborting due to previous error; 6 warnings emitted
teovoinea commented 4 years ago

I followed @gamma-delta's instructions but now I'm getting error: process didn't exit successfully: `target\release\examples\client.exe G:\models G:\voice.ogg` (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND)

Summary of what I did:

At this point it compiles fine now that it can find the libdeepspeech.so.if file. However when I try to run any of the examples or tests or the binary in general I see that STATUS_DLL_NOT_FOUND error.

What's confusing me the most is I thought this would be statically linking the library so why is it looking for a DLL in the first place?

Saviio commented 2 years ago

@teovoinea

I have met this issue like you, have you resolve this problem?

Saviio commented 2 years ago

oh, i have added set rustc-link-search= C:\deepspeech before I run cargo run --release --example client

example/client can be run successfully.

but In my scenario, I got another error:

Data loss: Can't parse .\models\deepspeech-0.9.3-models.tflite as binary proto