diff options
author | Elliott Hughes <enh@google.com> | 2014-01-13 16:36:06 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-01-13 16:36:06 -0800 |
commit | bf1e0bac82db4f1ce10b51781c136cb5671f59ed (patch) | |
tree | b428f16e11a3770143f389fd1d614ec853d3c47a /JniInvocation.cpp | |
parent | 3bd0c738d7999fd5908d435de5a941d3c16df297 (diff) | |
download | libnativehelper-bf1e0bac82db4f1ce10b51781c136cb5671f59ed.tar.gz |
Set LD_LIBRARY_PATH in Java apps.
This is the best place to put this because it handles both command-line
and GUI apps.
This change is needed to support 64-bit systems, where there may be
both 32-bit and 64-bit VMs at the same time.
Change-Id: Ifbc0ef18e7d7e5e188c77131ada2ce1e969bc064
Diffstat (limited to 'JniInvocation.cpp')
-rw-r--r-- | JniInvocation.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/JniInvocation.cpp b/JniInvocation.cpp index acd019a..8c4aaf3 100644 --- a/JniInvocation.cpp +++ b/JniInvocation.cpp @@ -49,12 +49,26 @@ JniInvocation::~JniInvocation() { } #ifdef HAVE_ANDROID_OS +extern "C" void android_get_LD_LIBRARY_PATH(char*, size_t); + +void Init_LD_LIBRARY_PATH() { + char ld_library_path[PATH_MAX]; + android_get_LD_LIBRARY_PATH(ld_library_path, sizeof(ld_library_path)); + setenv("LD_LIBRARY_PATH", ld_library_path, 0); +} +#endif + +#ifdef HAVE_ANDROID_OS static const char* kLibrarySystemProperty = "persist.sys.dalvik.vm.lib"; #endif static const char* kLibraryFallback = "libdvm.so"; bool JniInvocation::Init(const char* library) { #ifdef HAVE_ANDROID_OS + Init_LD_LIBRARY_PATH(); +#endif + +#ifdef HAVE_ANDROID_OS char default_library[PROPERTY_VALUE_MAX]; property_get(kLibrarySystemProperty, default_library, kLibraryFallback); #else |