Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

thevibesman

macrumors regular
Original poster
Oct 26, 2007
139
0
I am having some trouble building a JNI library with Xcode. I have included JavaVM.framework in my project and included the headers. Xcode has no problem resolving defines like JNI_TRUE , JNI_EXPORT , JNI_Call and types like jfloat and jfloatArray . If I write a library with only simple functions using the JNI types everything is fine. The problem comes when I try to use any of the JNI functions such as GetFloatArrayElements(JNIEnv*,jfloatArray,jboolean*) throw an undefined symbol when linking.

I have tried the versions of JavaVM.framework with the 10.6,10.7, and 10.8 SDKs. I have tried with and without adding both the headers and the framework to my build settings in addition to adding the framework in my build phases. I have tried including both jni.h and JavaVM/jni.h.

Does anyone have any suggestions for this or a sample JNI Xcode 4 project they could share? I have read elsewhere about a JNI template with Xcode 4 but I couldn't find anything like that.
 
Never mind, it was an error in my code.

For anyone else's reference, if you link with the JavaVM library, all you must do is include <JavaVM/jni.h> instead of <jni.h> and nothing else will need to be changed in your build settings.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.