Hello Guest

[Solved]OpenCL[LWJGL] Failed to load a library; Missing JAR file

  • 2 Replies
Code: [Select]
java -cp Dependencies/lwjgl/*:. com.evanstools.opencl.demo.Demo
[LWJGL] Failed to load a library. Possible solutions:
a) Set -Djava.library.path or -Dorg.lwjgl.librarypath to the directory that contains the shared libraries.
b) Add the JAR(s) containing the shared libraries to the classpath.
[LWJGL] Enable debug mode with -Dorg.lwjgl.util.Debug=true for better diagnostics.
[LWJGL] Enable the SharedLibraryLoader debug mode with -Dorg.lwjgl.util.DebugLoader=true for better diagnostics.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to locate library: libOpenCL.so
at org.lwjgl.system.Library.loadNative(Library.java:207)
at org.lwjgl.system.Library.loadNative(Library.java:251)
at org.lwjgl.opencl.CL.create(CL.java:54)
at org.lwjgl.opencl.CL.<clinit>(CL.java:43)
at org.lwjgl.opencl.CL10.nclGetPlatformIDs(CL10.java:394)
at org.lwjgl.opencl.CL10.clGetPlatformIDs(CL10.java:417)
at com.evanstools.opencl.demo.Demo.main(Demo.java:10)

I was under the impression in this version of lwjgl that everything was somehow packaged inside of the jar files. I'm not sure where are the files/libraries?
   a) Set -Djava.library.path or -Dorg.lwjgl.librarypath to the directory that contains the shared libraries.

Code: [Select]
package com.evanstools.opencl.demo;
import static org.lwjgl.opencl.CL10.*;
import org.lwjgl.*;
import java.nio.*;
import static org.lwjgl.BufferUtils.*;
class Demo{
  public static void main(String[] args){
    PointerBuffer platforms = null;
    IntBuffer num_platforms = null;
    /*PointerBuffer devices = null;
    IntBuffer numberOfDevices = null;

Code: [Select]
[LWJGL] Loading library: OpenCL
[LWJGL] libOpenCL.so not found in org.lwjgl.librarypath=/tmp/lwjglevan/3.1.1-build-16
[LWJGL] libOpenCL.so not found in java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
[LWJGL] libOpenCL.so not found in system paths
[LWJGL] Failed to load a library. Possible solutions:
Missing lwjgl-opencl-natives...jar files with libOpenCL.so!


https://build.lwjgl.org/stable/bin/lwjgl-opencl/khronos_license.txt   Download
https://build.lwjgl.org/stable/bin/lwjgl-opencl/lwjgl-opencl-javadoc.jar   Download
https://build.lwjgl.org/stable/bin/lwjgl-opencl/lwjgl-opencl-sources.jar   Download
https://build.lwjgl.org/stable/bin/lwjgl-opencl/lwjgl-opencl.jar   Download
« Last Edit: May 24, 2017, 20:19:25 by Evan407 »


Offline spasi

  • *****
  • 2006
    • WebHotelier
Re: [LWJGL] Failed to load a library; Missing JAR file
« Reply #1 on: May 24, 2017, 17:59:01 »
LWJGL does not provide libOpenCL.so, just like it doesn't provide an OpenGL implementation. OpenCL must be installed on your system separately, usually with your GPU drivers. You could also have multiple OpenCL platforms (e.g. the Intel OpenCL runtime with a CPU device and the Nvidia OpenCL implementation with a GPU device), in which case libOpenCL.so is the ICD loader (ICD = Installable Client Drivers) that can be used to choose one or the other (or both).

Re: [LWJGL] Failed to load a library; Missing JAR file
« Reply #2 on: May 24, 2017, 20:09:43 »
Okay I
Code: [Select]
apt install ocl-icd-opencl-dev
It works!
Code: [Select]
java -Dorg.lwjgl.util.Debug=true -Dorg.lwjgl.util.DebugLoader=true -cp Dependencies/lwjgl/*:. com.evanstools.opencl.demo.Demo
[LWJGL] Version: 3.1.1 build 16
[LWJGL]     OS: Linux v4.8.0-52-generic
[LWJGL]    JRE: 1.8.0_131 amd64
[LWJGL]    JVM: OpenJDK 64-Bit Server VM v25.131-b11 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL]    Using SharedLibraryLoader...
[LWJGL]    Found at: /tmp/lwjglevan/3.1.1-build-16/liblwjgl.so
[LWJGL]    Loaded from org.lwjgl.librarypath: /tmp/lwjglevan/3.1.1-build-16/liblwjgl.so
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Loading library: OpenCL
[LWJGL]    libOpenCL.so not found in org.lwjgl.librarypath=/tmp/lwjglevan/3.1.1-build-16
[LWJGL]    Loaded from java.library.path: /usr/lib/x86_64-linux-gnu/libOpenCL.so
« Last Edit: May 24, 2017, 20:28:55 by Evan407 »