Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Could not load X: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path #393

Closed
jpsacha opened this issue Apr 16, 2020 · 11 comments

Comments

@jpsacha
Copy link
Member

jpsacha commented Apr 16, 2020

I am getting warnings while running JavaCPP 1.5.3 or JavaCPP presets (VideoInput etc) on Windows

Warning: Could not load Loader: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path: [...]

Warning: Could not load Pointer: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path: [...]

Warning: Could not load BytePointer: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path: [...]

where [...] is the system path variable value

The code seems to be working, just the warnings being printed.

Some hints what may be going on?

@saudet
Copy link
Member

saudet commented Apr 17, 2020

As explained at bytedeco/javacv#1305 we now need to add a dependency on an artifact containing that library, that is all. All presets have already been updated, so we don't need to do anything special. How are you getting this warning?

@jpsacha
Copy link
Member Author

jpsacha commented Apr 17, 2020

Based on bytedeco/javacv#1305 discussion, It is not clear to me what dependency should be added.

I updated the flandmark example to use JavaCPP 1.5.3. It illustrates the issue.

  • you get first warning when you start SBT from command prompt (javacpp is used by SBT to determine platform to add proper dependencies, see project/plugin.sbt)
Warning: Could not load Loader: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path: ...
  • when you do run to start the example you get more warnings, but example is working

Here is the code from SBT configuration (build.sbt) that sets the dependencies:

// Platform classifier for native library dependencies
lazy val platform = org.bytedeco.javacpp.Loader.getPlatform

// @formatter:off
libraryDependencies ++= Seq(
  "org.bytedeco" % "javacv"    % "1.5.3",
  "org.bytedeco" % "flandmark" % "1.07-1.5.3"  classifier "",
  "org.bytedeco" % "flandmark" % "1.07-1.5.3"  classifier platform,
  "org.bytedeco" % "openblas"  % "0.3.9-1.5.3" classifier "",
  "org.bytedeco" % "openblas"  % "0.3.9-1.5.3" classifier platform,
  "org.bytedeco" % "opencv"    % "4.3.0-1.5.3" classifier "",
  "org.bytedeco" % "opencv"    % "4.3.0-1.5.3" classifier platform
)

Do you mean that some additional dependency should be added here?

@saudet
Copy link
Member

saudet commented Apr 18, 2020

You're missing this dependency:

 "org.bytedeco" % "javacpp" % "1.5.3" classifier platform

@jpsacha
Copy link
Member Author

jpsacha commented Apr 18, 2020

That solves part of the problem. Adding the dependency stops warnings after SBT loaded and executes code.

The remaining problem is that platform is determined by calling org.bytedeco.javacpp.Loader.getPlatform - for that SBT project loader depends on javacpp (in project/plugin.sbt), at that point platform is not yet know.

On other hand, Warning: Could not load ... is just a warning and code works. May be the actual problem is with the warning itself - may be it should not be issued?

jpsacha added a commit to bytedeco/javacv-examples that referenced this issue Apr 18, 2020
@saudet
Copy link
Member

saudet commented Apr 19, 2020 via email

@saudet
Copy link
Member

saudet commented Apr 19, 2020

Unless you're OK with unfixing bytedeco/javacv#1305, yes we need that warning/error.

@saudet
Copy link
Member

saudet commented Apr 19, 2020

If sbt uses a different class loader for executing build.sbt than the one used to build and execute user code, then we could add a flag to disable the log before calling Loader.getPlatform():
https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/tools/Logger.java
Would that be satisfactory?

@jpsacha
Copy link
Member Author

jpsacha commented Apr 20, 2020

Looks that logging levels are right now hard coded, so it will be good to have flexibility to set them through API.

In case of Loader.getPlatform() it would be great to have an optional parameter, say boolean printWarning that can disable warning for that call.

When Loader.getPlatform() is called it really does not need a native libraries, so most natural way would be to, by default, disable the warning about missing jnijavacpp.

@saudet
Copy link
Member

saudet commented Apr 20, 2020

We can't transparently disable the warning without risking to unfix bytedeco/javacv#1305. You're the one who posted it, so I'm sure you wouldn't like that! But I think we can work around the problem by moving the code for Loader.getPlatform() to another class...

@saudet saudet reopened this Apr 20, 2020
@saudet saudet added the bug label Apr 20, 2020
saudet added a commit that referenced this issue Apr 21, 2020
@saudet
Copy link
Member

saudet commented Apr 21, 2020

Ok, I've added the Loader.Detector class in the last commit above, so try to call Loader.Detector.getPlatform() instead. That will not attempt to load any native libraries.

jpsacha added a commit to bytedeco/javacv-examples that referenced this issue Apr 24, 2020
@jpsacha
Copy link
Member Author

jpsacha commented Apr 24, 2020

Thanks. It works well with the new Detector. Tested with official snapshot.

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

No branches or pull requests

2 participants