Search code examples
javamacosgpuopenclaparapi

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


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?


Solution

  • 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!