bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.61k stars 1.59k forks source link

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

Open heshanthenura opened 8 months ago

heshanthenura commented 8 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 8 months ago

Please try again with version 1.5.10

heshanthenura commented 8 months ago

Ill try and tell you.

saudet commented 8 months ago

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

heshanthenura commented 8 months ago

Thank you, I'll try.

codespearhead commented 8 months ago

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

steeveen commented 8 months ago

I met the same problem and searching for help……

codespearhead commented 8 months ago

Can you provide us with an MRE?

steeveen commented 8 months ago

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

steeveen commented 8 months ago

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

codespearhead commented 8 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 8 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 8 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 8 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 8 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 8 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.

cbrautigam2 commented 3 months ago

I'm getting the original problem cited about the jniopenblas_nolapack not found. I've simply cloned the repo (version 1.5.10) and I'm trying to run the OpticalFlowDense.java example. Not having any luck find a solution on google. I'm using RHEL 9. Getting this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopenblas_nolapack in java.library.path: /home/cbrautigam/.javacpp/cache/lib64:/usr/local/lib:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib 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:2063) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1832) at org.bytedeco.javacpp.Loader.load(Loader.java:1423) at org.bytedeco.javacpp.Loader.load(Loader.java:1234) at org.bytedeco.javacpp.Loader.load(Loader.java:1210) at 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.Loader.load(Loader.java:1289) at org.bytedeco.javacpp.Loader.load(Loader.java:1234) at org.bytedeco.javacpp.Loader.load(Loader.java:1210) at org.bytedeco.opencv.global.opencv_imgcodecs.<clinit>(opencv_imgcodecs.java:18) at OpticalFlowDense.main(OpticalFlowDense.java:20) Caused by: java.lang.UnsatisfiedLinkError: Could not find jniopenblas_nolapack in class, module, and library paths. at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1799) ... 12 more

saudet commented 3 months ago

Please set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more information on the console.

cbrautigam2 commented 3 months ago

Here it is:

Debug: Loading class org.bytedeco.javacpp.presets.javacpp Debug: Loading class org.bytedeco.openblas.global.openblas_nolapack Debug: Loading class org.bytedeco.javacpp.presets.javacpp Debug: Loading class org.bytedeco.openblas.global.openblas_nolapack Debug: Loading /lib64/libgcc_s.so.1 Debug: Loading /lib64/libquadmath.so.0 Debug: Loading /lib64/libgfortran.so.5 Debug: Loading library gfortran Debug: Failed to load for gfortran@.4: java.lang.UnsatisfiedLinkError: no gfortran in java.library.path: /usr/local/lib:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib Debug: Loading library gfortran Debug: Failed to load for gfortran@.3: java.lang.UnsatisfiedLinkError: no gfortran in java.library.path: /usr/local/lib:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib Debug: Loading /home/cbrautigam/.javacpp/cache/lib64/libopenblas_nolapack.so.0 Debug: Loading library jniopenblas_nolapack Debug: Failed to load for jniopenblas_nolapack: java.lang.UnsatisfiedLinkError: no jniopenblas_nolapack in java.library.path: /usr/local/lib:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopenblas_nolapack in java.library.path: /usr/local/lib:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib 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:2063) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1832) at org.bytedeco.javacpp.Loader.load(Loader.java:1423) at org.bytedeco.javacpp.Loader.load(Loader.java:1234) at org.bytedeco.javacpp.Loader.load(Loader.java:1210) at 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.Loader.load(Loader.java:1289) at org.bytedeco.javacpp.Loader.load(Loader.java:1234) at org.bytedeco.javacpp.Loader.load(Loader.java:1210) at org.bytedeco.opencv.global.opencv_imgcodecs.<clinit>(opencv_imgcodecs.java:18) at OpticalFlowDense.main(OpticalFlowDense.java:20) Caused by: java.lang.UnsatisfiedLinkError: Could not find jniopenblas_nolapack in class, module, and library paths. at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1799) ... 12 more

saudet commented 3 months ago

It looks like the libjniopenblas_nolapack.so isn't in your class path, you'll need to figure out why

javadroider commented 4 weeks ago

I'm also facing the problem. It works well in windows, but failing in Ubuntu. Do I need to run any specific steps for Ubuntu?

2024-11-05 12:54:56 java.lang.UnsatisfiedLinkError: no jniopenblas_nolapack in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
2024-11-05 12:54:56     at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458)
2024-11-05 12:54:56     at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916)
2024-11-05 12:54:56     at java.base/java.lang.System.loadLibrary(System.java:2063)
2024-11-05 12:54:56     at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1832)
2024-11-05 12:54:56     at org.bytedeco.javacpp.Loader.load(Loader.java:1423)
2024-11-05 12:54:56     at org.bytedeco.javacpp.Loader.load(Loader.java:1234)
2024-11-05 12:54:56     at org.bytedeco.javacpp.Loader.load(Loader.java:1210)
2024-11-05 12:54:56     at org.bytedeco.openblas.global.openblas_nolapack.<clinit>(openblas_nolapack.java:12)
2024-11-05 12:54:56     at java.base/java.lang.Class.forName0(Native Method)
2024-11-05 12:54:56     at java.base/java.lang.Class.forName(Class.java:534)
2024-11-05 12:54:56     at java.base/java.lang.Class.forName(Class.java:513)
2024-11-05 12:54:56     at org.bytedeco.javacpp.Loader.load(Loader.java:1289)
2024-11-05 12:54:56     at org.bytedeco.javacpp.Loader.load(Loader.java:1234)
2024-11-05 12:54:56     at org.bytedeco.javacpp.Loader.load(Loader.java:1226)

2024-11-05 12:54:56 Caused by: java.lang.UnsatisfiedLinkError: /root/.javacpp/cache/openblas-0.3.26-1.5.10-linux-x86_64.jar/org/bytedeco/openblas/linux-x86_64/libjniopenblas_nolapack.so: /usr/glibc/lib/libm.so.6: version `GLIBC_2.29' not found (required by /root/.javacpp/cache/openblas-0.3.26-1.5.10-linux-x86_64.jar/org/bytedeco/openblas/linux-x86_64/libopenblas_nolapack.so.0)
2024-11-05 12:54:56     at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
2024-11-05 12:54:56     at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
2024-11-05 12:54:56     at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
2024-11-05 12:54:56     at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
2024-11-05 12:54:56     at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418)
2024-11-05 12:54:56     at java.base/java.lang.Runtime.load0(Runtime.java:852)
2024-11-05 12:54:56     at java.base/java.lang.System.load(System.java:2025)
2024-11-05 12:54:56     at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1779)
2024-11-05 12:54:56     ... 13 common frames omitted
saudet commented 4 weeks ago

@javadroider Please upgrade your version of Ubuntu

javadroider commented 4 weeks ago

Apologies for the confusion, I'm using Alpine as per the following docker file. Does it not support Alpine? Do you have any recommendations?

FROM ubuntu:22.04
RUN apt-get install nvidia-cuda-toolkit

FROM bellsoft/liberica-openjdk-alpine:21.0.2
VOLUME /tmp
ADD target/app-service-0.0.1-SNAPSHOT.jar app.jar

COPY target/classes/elasticsearch.jks /opt/xperio/elasticsearch.jks

RUN sh -c 'touch /app.jar'

EXPOSE 8090

ENTRYPOINT [ "sh", "-c", "java -Dspring.profiles.active=qa -jar /app.jar" ]
saudet commented 2 weeks ago

@javadroider Please refer to issue https://github.com/bytedeco/javacpp-presets/issues/1379