mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
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:
parent
a688a6f61a
commit
36f1d3206e
@ -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);
|
||||
|
6
makefile
6
makefile
@ -13,12 +13,14 @@ ifeq ($(platform),Darwin)
|
||||
rdynamic =
|
||||
thread-cflags =
|
||||
shared = -dynamiclib
|
||||
so-extension = dylib
|
||||
so-extension = jnilib
|
||||
ld-library-path = DYLD_LIBRARY_PATH
|
||||
else
|
||||
rdynamic = -rdynamic
|
||||
thread-cflags = -pthread
|
||||
shared = -shared
|
||||
so-extension = so
|
||||
ld-library-path = LD_LIBRARY_PATH
|
||||
endif
|
||||
|
||||
mode = debug
|
||||
@ -154,7 +156,7 @@ $(input): $(classpath-objects)
|
||||
|
||||
.PHONY: run
|
||||
run: $(executable) $(input)
|
||||
LD_LIBRARY_PATH=$(bld) $(<) $(args)
|
||||
$(ld-library-path)=$(bld) $(<) $(args)
|
||||
|
||||
.PHONY: debug
|
||||
debug: $(executable) $(input)
|
||||
|
@ -25,6 +25,12 @@
|
||||
#error "Unsupported architecture"
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define SO_SUFFIX ".jnilib"
|
||||
#else
|
||||
#define SO_SUFFIX ".so"
|
||||
#endif
|
||||
|
||||
#define NO_RETURN __attribute__((noreturn))
|
||||
|
||||
#define LIKELY(v) __builtin_expect((v) != 0, true)
|
||||
|
@ -597,15 +597,9 @@ class MySystem: public System {
|
||||
void* p;
|
||||
unsigned nameLength = (name ? strlen(name) : 0);
|
||||
if (mapName) {
|
||||
#ifdef __APPLE__
|
||||
unsigned size = nameLength + 10;
|
||||
unsigned size = nameLength + 3 + sizeof(SO_SUFFIX);
|
||||
char buffer[size];
|
||||
snprintf(buffer, size, "lib%s.dylib", name);
|
||||
#else
|
||||
unsigned size = nameLength + 7;
|
||||
char buffer[size];
|
||||
snprintf(buffer, size, "lib%s.so", name);
|
||||
#endif
|
||||
snprintf(buffer, size, "lib%s" SO_SUFFIX, name);
|
||||
p = dlopen(buffer, RTLD_LAZY);
|
||||
} else {
|
||||
p = dlopen(name, RTLD_LAZY);
|
||||
|
Loading…
Reference in New Issue
Block a user