Hi all. I'm trying to compile a very, very simple ...
# native
r
Hi all. I'm trying to compile a very, very simple set of JNI bindings (written in C++), for use in a JVM application, and it's been an absolute nightmare. Everything gradle+native seems under-documented and half finished. What I want to do is: 1. Compile src/main/cpp/libfoo-jni.cpp for Android using the ndk. This was super easy using
android { externalNativeBuild {} }
. 2. Compile src/main/cpp/libfoo-jni.cpp for windows (jvm) in the same way. Ideally using clang+cmake for consistency with Android. This has been a nightmare. So far I've tried: 1. Using nokee (jni-library, cpp-language). This gets me to the compilation step (hooray), but it's forcing use of MSVC, which is not compatible with my JNI bindings. I need to use clang or gcc. The docs say this is configurable, but not how to do so. The nokee sample projects are useless, because they're mainly demos of "look at how you don't need to configure anything!". 2. Using (com.cisco.external-build). I'm unable to get this working at all, because (1) all examples are in groovy, use magic, and are unclear how to port to kotlin, and (2) even using groovy, it seems like the plugin no longer works This whole process is making me feel stupid. I'm definitely a beginner at Gradle, but I've never run into difficulties of this magnitude with any other build system I've used (xcode, cmake, make etc..). Would I be better off trying to avoid using Gradle as much as possible for this and manually writing scripts to exec? I feel like this is the tool pushing back on me.
t
Getting clang on windows set up is generally difficult, but the way gradle does things is even harder. Is there something specific causing MSVC to not work? Assuming you’re not using any Linux or android system headers, msvc should generally work. And if you are using those, even clang wouldn’t help because clang on windows still has to use the windows headers