0

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?

Hülya
  • 3,353
  • 2
  • 12
  • 19
Stefano
  • 409
  • 1
  • 5
  • 10
  • I do not know Aparapi but I guess your LD_LIBRARY_PATH is not correct. It could be specified per Java System Property like `-Djava.library.path=...` – Michal May 12 '19 at 09:53
  • It looks for a library with machine code which is unavailable. Did you investigate what the exception means? – Thorbjørn Ravn Andersen May 12 '19 at 09:57
  • Maybe [this question](https://stackoverflow.com/questions/56060097/ecplise-java-jni-java-lang-unsatisfiedlinkerror-loading-dll/5607231) will be of help? – Abra May 12 '19 at 10:12
  • I've already read different answers, and next, I add the flag "-Djava.library.path=\path\lib\.." but it doesn't work. @Michal Do you have any suggestions or examples? – Stefano May 12 '19 at 11:03
  • @Abra it is similar problem, and I've already copied all resources file. However, It doesn't work. – Stefano May 12 '19 at 11:07
  • @ThorbjørnRavnAndersen I think it's a problem with JNI or libraries because I tried the same code on Windows and it only works by adding the Aparapi dependency to the pom file. – Stefano May 12 '19 at 11:10
  • @Stefano: Did you try setting the LD_LIBRARY_PATH? – Michal May 12 '19 at 18:18
  • @Michal How should I set this path? – Stefano May 13 '19 at 10:29
  • @Stefano: it looks like the variable is called DYLD_LIBRARY_PATH on OSX. At best set it via launchctl, see https://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-yosemite Or make a symbolic link of it into /usr/local/lib , see https://github.com/nteract/nteract/issues/1523 It looks like it is quite messy on OSX ( – Michal May 13 '19 at 12:04
  • @MichalI Unfortunately, I don't solve the problem. – Stefano May 13 '19 at 14:34

2 Answers2

0

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.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
0

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!

Stefano
  • 409
  • 1
  • 5
  • 10