The proper extension for Mac JNI libraries is .jnilib. Hard-coded constants

have been factored to common locations.  Furthermore, the LD_LIBRARY_PATH
environment variable is DYLD_LIBRARY_PATH on Mac OS X.
This commit is contained in:
Eric Scharff
2007-09-20 10:13:41 -06:00
parent a688a6f61a
commit 36f1d3206e
4 changed files with 20 additions and 12 deletions

View File

@ -6,6 +6,12 @@
#include "jni.h"
#include "jni-util.h"
#ifdef __APPLE__
#define SO_SUFFIX ".jnilib"
#else
#define SO_SUFFIX ".so"
#endif
#undef JNIEXPORT
#define JNIEXPORT __attribute__ ((visibility("default")))
@ -54,9 +60,9 @@ Java_java_lang_System_doMapLibraryName(JNIEnv* e, jclass, jstring name)
const char* chars = e->GetStringUTFChars(name, 0);
if (chars) {
unsigned nameLength = strlen(chars);
unsigned size = nameLength + 7;
unsigned size = nameLength + 3 + sizeof(SO_SUFFIX);
char buffer[size];
snprintf(buffer, size, "lib%s.so", chars);
snprintf(buffer, size, "lib%s" SO_SUFFIX, chars);
r = e->NewStringUTF(buffer);
e->ReleaseStringUTFChars(name, chars);