From 1fb83dbf0d887ca28dedfc772525c18f9e2753a9 Mon Sep 17 00:00:00 2001 From: gardners Date: Tue, 18 Oct 2011 23:45:46 +1030 Subject: [PATCH] Android linker is really dumb, so made simple dlopen() based wrapper to pull in the DNA/NaCl library and run the DNA main function from there. So now dna binary still works, but uses libdnalib, so that we don't need to duplicate NaCl library for dna binary versus access from in Java (once we make the JNI wrappers for the functions we care about). --- Android-without-NaCl.mk | 3 +-- dnawrap.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 dnawrap.c diff --git a/Android-without-NaCl.mk b/Android-without-NaCl.mk index 50ae066b..019d0c8d 100644 --- a/Android-without-NaCl.mk +++ b/Android-without-NaCl.mk @@ -43,8 +43,7 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) -LOCAL_SHARED_LIBRARIES:= dnalib LOCAL_MODULE:= dna -LOCAL_SRC_FILES:= null.c +LOCAL_SRC_FILES:= dnawrap.c include $(BUILD_EXECUTABLE) diff --git a/dnawrap.c b/dnawrap.c new file mode 100644 index 00000000..73e6c901 --- /dev/null +++ b/dnawrap.c @@ -0,0 +1,11 @@ +#include +#include + +int main(int argc,char **argv) +{ + void *h = dlopen("/data/data/org.servalproject/lib/libdnalib.so",RTLD_LAZY); + int (*dnamain)(int,char **) = dlsym(h,"main"); + if (!dnamain) return fprintf(stderr,"Could not load libdnalib.so\n"); + return (*dnamain)(argc,argv); + +}