Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

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

Open
LeSplooch opened this issue Feb 7, 2020 · 25 comments
Open

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

LeSplooch opened this issue Feb 7, 2020 · 25 comments

Comments

@LeSplooch
Copy link

LeSplooch commented Feb 7, 2020

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
Copy link
Member

est31 commented Feb 7, 2020

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

@LeSplooch
Copy link
Author

LeSplooch commented Feb 7, 2020

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
Copy link
Member

est31 commented Feb 7, 2020

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

@LeSplooch
Copy link
Author

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

@est31
Copy link
Member

est31 commented Apr 27, 2020

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

@LeSplooch
Copy link
Author

@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
Copy link
Member

est31 commented Apr 28, 2020

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

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

@LeSplooch
Copy link
Author

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
Copy link
Member

est31 commented May 1, 2020

@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
Copy link
Author

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
Copy link
Member

est31 commented May 14, 2020

It's not needed any more, see 9876695

@LeSplooch
Copy link
Author

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
Copy link
Member

est31 commented May 14, 2020

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
Copy link
Author

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

@gamma-delta
Copy link

I'm also having this problem.

@gamma-delta
Copy link

gamma-delta commented May 24, 2020

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
Copy link

gamma-delta commented May 24, 2020

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
Copy link
Member

est31 commented May 24, 2020

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

@gamma-delta
Copy link

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
Copy link

retep998 commented Jul 7, 2020

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
Copy link
Author

@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
Copy link
Author

LeSplooch commented Jul 21, 2020

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
Copy link

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:

  • Created vendored directory in my project where I cloned https://github.com/RustAudio/deepspeech-rs/ at commit f94b98d429bdac30b9b9aaa048946537b6ebd575 (it was the last successfully building one)
  • Downloaded native_client for windows and put it in vendored/deepspeech-win
  • Modified vendored/deepspeech-rs/sys/build.rs according to this comment cannot open input file 'deepspeech.lib' / Windows 10 #25 (comment) replacing the directory with vendored/deepspeech-win

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
Copy link

Saviio commented Dec 5, 2021

@teovoinea

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

@Saviio
Copy link

Saviio commented Dec 5, 2021

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants