bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.39k stars 1.56k forks source link

java.lang.UnsatisfiedLinkError: Could not find jniopenblas_nolapack in class, module, and library paths #2203

Open heshanthenura opened 3 months ago

heshanthenura commented 3 months ago

anyone know how to fix this error?

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopenblas_nolapack in java.library.path: E:\Coding\Java\JAVASDKs\JDK21\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;E:\Coding\Java\JAVASDKs\JDK21\bin;C:\Gradle\gradle-8.5\bin;E:\Programs\Git\cmd;E:\Windows Kits\10\Windows Performance Toolkit\;C:\Users\hesha\AppData\Local\Microsoft\WindowsApps;E:\Programs\VSCode\bin;C:\Users\hesha\AppData\Local\GitHubDesktop\bin;E:\Programs\IntelliJ IDEA 2023.3\bin;;E:\Programs\apache-maven-3.9.6\bin;E:\Programs\depot_tools;;E:\Programs\IntelliJ Com\IntelliJ IDEA Community Edition 2023.3.4\bin;;E:\Programs\nim-2.0.2_x64\nim-2.0.2\bin;C:\Users\hesha\.nimble\bin;.
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916)
    at java.base/java.lang.System.loadLibrary(System.java:2059)
    at org.bytedeco.javacpp/org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1832)
    at org.bytedeco.javacpp/org.bytedeco.javacpp.Loader.load(Loader.java:1423)
    at org.bytedeco.javacpp/org.bytedeco.javacpp.Loader.load(Loader.java:1234)
    at org.bytedeco.javacpp/org.bytedeco.javacpp.Loader.load(Loader.java:1210)
    at org.bytedeco.openblas/org.bytedeco.openblas.global.openblas_nolapack.<clinit>(openblas_nolapack.java:12)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:534)
    at java.base/java.lang.Class.forName(Class.java:513)
    at org.bytedeco.javacpp/org.bytedeco.javacpp.Loader.load(Loader.java:1289)
    at org.bytedeco.javacpp/org.bytedeco.javacpp.Loader.load(Loader.java:1234)
    at org.bytedeco.javacpp/org.bytedeco.javacpp.Loader.load(Loader.java:1210)
    at org.bytedeco.opencv/org.bytedeco.opencv.global.opencv_imgcodecs.<clinit>(opencv_imgcodecs.java:18)
    at com.heshanthenura.javafxcv@1.0-SNAPSHOT/com.heshanthenura.javafxcv.JavaFXCV.main(JavaFXCV.java:13)
Caused by: java.lang.UnsatisfiedLinkError: Could not find jniopenblas_nolapack in class, module, and library paths.
    at org.bytedeco.javacpp/org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1799)
    ... 12 more

FAILURE: Build failed with an exception.
saudet commented 3 months ago

Please try again with version 1.5.10

heshanthenura commented 3 months ago

Ill try and tell you.

saudet commented 3 months ago

Please follow the instructions at https://github.com/bytedeco/javacpp-presets/wiki/Debugging-UnsatisfiedLinkError-on-Windows

heshanthenura commented 3 months ago

Thank you, I'll try.

codespearhead commented 3 months ago

Did it work? If so, can you close this issue?

steeveen commented 3 months ago

I met the same problem and searching for help……

codespearhead commented 3 months ago

Can you provide us with an MRE?

steeveen commented 3 months ago

Just Call ‘Loader.load(opencv_java.class)’ under RHEL-7, Java 8 ,SpringBoot 2.7.2

steeveen commented 3 months ago

with the dependency of javacv-platform 1.5.10, opencv-platform 1.5.10 , openblas-platform 1.5.10

codespearhead commented 3 months ago

It's worth noting that Spring Boot 2.7 no longer has OSS support.

I just tried it with my current setup and everything worked as expected (Spring Boot 3.2.4, OpenJDK Temurin-17.0.10+7).

  1. Create a Spring Boot project:
mkdir mre &&
cd mre &&
curl https://start.spring.io/starter.tgz -d dependencies=web,devtools -d type=maven-project | tar -xzvf -
  1. Add JavaCV to it:
<dependency>
    <groupId>org.bytedeco</groupId>
    <artifactId>javacv-platform</artifactId>
    <version>1.5.10</version>
</dependency>
  1. Create an endpoint that invokes Loader.load(opencv_java.class):
package com.example.demo;

import org.bytedeco.javacpp.Loader;
import org.bytedeco.opencv.opencv_java;
import org.bytedeco.opencv.global.opencv_core;
import org.bytedeco.opencv.opencv_core.Mat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Demo {

    @GetMapping
    public String doGet(){
        Loader.load(opencv_java.class);
        Mat mat = Mat.eye(3, 3, opencv_core.CV_8UC1).asMat();
        return "mat = " + mat.toString() + "\n";
    }

}
  1. Call the endpoint:
curl localhost:8080
# mat = org.bytedeco.opencv.opencv_core.Mat[width=3,height=3,depth=8,channels=1]
steeveen commented 3 months ago

Did you do your test on red hat OS? My code can run well on windows10 but meet problem just on redhat7.

codespearhead commented 3 months ago

I am not in a position to directly experiment with the suggested setup at this time.

For anyone who is though, try creating a Dockerfile in the root directory of the MRE with the following content:

FROM registry.access.redhat.com/ubi8/openjdk-17:1.19-1

WORKDIR /app
COPY . .

RUN mvn clean package -DskipTests
EXPOSE 8080

CMD ["java", "-jar", "target/app-0.0.1-SNAPSHOT.jar"]

Then run:

docker build -t demo:tag . &&
docker run --rm -it demo:tag
steeveen commented 3 months ago

I have a further problem. I found that problem is caused by that there is no CXXABI 1.3.8 in my environment. Does anyone have any idea on this?

codespearhead commented 3 months ago

I haven't used this library long enough to be able to troubleshoot problems, but I noticed it works out of the box in WSL (Ubuntu), but not in Git Bash (Windows), so I have a feeling strange errors might occur if you don't have GCC globally available in your environment when installing the dependencies. I haven't tested that theory though.

steeveen commented 3 months ago

I got the libstdc.6.0.28.so, which can support CXXABI_1_3_8. I would have a try to replace libstdc.6.0.19.so with this file. I hope it can work.