gpu / JOCL

Java bindings for OpenCL
http://www.jocl.org
Other
183 stars 33 forks source link

Fix build for Android Studio and older jni.h versions #43

Closed starcatter closed 2 years ago

starcatter commented 2 years ago

Older releases of JNI, particularily the one that ships with the Android SDK, feature an incompatible signature for JNIInvokeInterface::AttachCurrentThread(), which expects the type JNIEnv** rather than the void** present in later revisions. This pull request handles this incompatibility by detecting whether JNI_VERSION_1_8 is defined (the oldest revision I found that had updated method signatures) and casts the parameter accordingly.

Additionally I updated C-style casts of JNIEnv** to void** with reinterpret_cast, because the version of Clang Android Studio uses complains about that.

The goal here is to get the native part of JOCL to build in Android studio, which greatly simplifies building for Android - just add JOCL's native sources and CMake files to an Android Studio "native" project and it will take care of building it and including the libraries within the apk file.

gpu commented 2 years ago

I think that it's not possible to delete a PR, not even for the repository owner, at least according to https://stackoverflow.com/a/18318431. But you might want to have a closer look at that stackoverflow Q/A - I think it might be possible to modify your branch (which this PR refers to) to "hide" the commit (and this is the important part here).

(It might work with a careful use of --hard/-f (force) at the right place, but I have never tried that, and am not a git guru).

For now, I'll edit my comments in the other PR to avoid mentioning this one (and you might edit your comments there as well), which will already make it very unlikely that anybody will see this PR here in the future.