Why does my .so library compiled with ndk won't work with error "cannot locate symbol "cblas_sdsdot" referenced by "libgsl.so""

69 views
Skip to first unread message

shekmun

unread,
Dec 29, 2015, 1:33:57 PM12/29/15
to android-ndk
I want to compile the gsl with ndk and use it on my android phone. And this is my steps:
1, Download the gsl-2.1.tar.gz and unzip it
2, ./configure -> make -> make install inside the gsl folder:
  a) ./configure --prefix=/path/to/install/directory --host="arm-linux-androideabi" --with-sysroot="/path/to/android-ndk-r10e/platforms/android-16/arch-arm" CC="/path/to/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc" STRIP="/path/to/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip" CFLAGS="--sysroot=/path/to/android-ndk-r10e/platforms/android-16/arch-arm -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" LDFLAGS="-nostdlib -Wl,--fix-cortex-a8" LIBS="-lgcc -ldl -lz -lm -lc"
  b) make -j4
  c) make install-strip
3, Now I get the libgsl.so and libgslcblas.so.
4, If I use the readelf to check the two librarys I get this:
  a) readelf -Ws libgsl.so | grep UND
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 00000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_finalize
     2: 00000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_atexit
     6: 00000000     0 FUNC    GLOBAL DEFAULT  UND malloc
     7: 00000000     0 FUNC    GLOBAL DEFAULT  UND free
    10: 00000000     0 FUNC    GLOBAL DEFAULT  UND memset
    52: 00000000     0 FUNC    GLOBAL DEFAULT  UND fread
    54: 00000000     0 FUNC    GLOBAL DEFAULT  UND fwrite
    62: 00000000     0 FUNC    GLOBAL DEFAULT  UND putc
    63: 00000000     0 FUNC    GLOBAL DEFAULT  UND fprintf
    65: 00000000     0 FUNC    GLOBAL DEFAULT  UND fscanf
   189: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND cblas_sdsdot ********pay attention this line******
   191: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND cblas_dsdot
   193: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND cblas_sdot
   195: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND cblas_ddot
  b) readelf -Ws libgslcblas.so | grep cblas_sdsdot
    12: 0000298c   268 FUNC    GLOBAL DEFAULT    8 cblas_sdsdot
5, See, the libgsl.so has an undefined symbol link "cblas_sdsdot" and libgslcblas.so defines it.
6, Add the libgsl.so and libgslcblas.so to my android studio. And load the two libraries with java code:
System.loadLibrary("gslcblas");
System.loadLibrary("gsl");
And when it runs to loadLibrary("gsl") the app will crash.
This is the error:
E/dalvikvm: dlopen("/data/app-lib/com.ict.hci.iwatcher-1/libgsl.so") failed: cannot locate symbol "cblas_sdsdot" referenced by "libgsl.so"...
It tell me that cannot find "cblas_sdsdot" and it is not defined libgsl.so but in libgslcblas.so. So how to tell android to find the symbol in libgslcblas.so?
7, I'm working on ubuntu 15.10(x64), android studio 1.5, ndk-r10e.
Reply all
Reply to author
Forward
0 new messages