undefined symbols JNI Xcode 4 Lion

Discussion in 'Mac Programming' started by thevibesman, Sep 22, 2012.

  1. thevibesman macrumors regular

    Oct 26, 2007
    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.
  2. thevibesman thread starter macrumors regular

    Oct 26, 2007
    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.

Share This Page