Error: "UnsatisfedLinkError: com.aparapi.internal.jni.OPENCLJNI.getPlatforms()" JNI configuration

109 Views Asked by At

I would try to execute an example script based on Aparapi, on MAC OS. I'm using the last version of Eclipse, but when I execute DeviceInfo example to get all the available devices:

public class DeviceInfo {
    public static void main(String[] args) {
        KernelPreferences preferences = KernelManager.instance().getDefaultPreferences();
        System.out.println("-- Devices in preferred order --");
        for (Device device : preferences.getPreferredDevices(null)) {
            System.out.println(device);
        }
    }
}

it generates the

java.lang.UnsatisfiedLinkError: com.amd.aparapi.OpenCLJNI.getPlatforms()Ljava/util/List"

Is there someone who can help me?

2

There are 2 best solutions below

0
Stefano On BEST ANSWER

Despite macOS Mojave 10.14.4 don't support directly OpenCL, I've executed Aparapi Framework.

I founded that the problem is the Aparapi Library. In particular, to resolve generated error I followed these steps:

  • Download this repository https://github.com/aparapi/aparapi for AMD Graphic Cards
  • Open the directory "com.amd.aparapi" and from terminal execute

    ant -f build.xml
    

    This command generates .jar file of this library

  • Add the generate jar to the project's classpath in Eclipse

  • Add the specific Aparapi library for your OS in:

    <your-workspace-path>/<your-project>/src/main/resources/osx/
    
  • Before to execute the code, add the VM argument in "Run Configuration"

    -Djava.library.path=<your-workspace-path>/<your-project>/src/main/resources/osx/
    
  • Execute your script!

1
Martin Zeitler On

build the native assembly for Mac (x86_64) and add it into jniLibs; here's the source code.

java.lang.UnsatisfiedLinkError generally means, that it cannot find the native assembly.