This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to access already generated .SO file functions in New Android Project?



My .so File Info:

"libvcsFPClient.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped."

So it was build in above format , now i'm trying to access via my project it shows following errors ,
" java.library.path: /usr/lib/jvm/java-6-openjdk/jre/lib/i386/client:/usr/lib/jvm/java-6-openjdk/jre/lib/i386:/usr/lib/jvm/java-6-openjdk/jre/../lib/i386:/usr/lib/jvm/java-6-openjdk/jre/lib/i386/client:/usr/lib/jvm/java-6-openjdk/jre/lib/i386::/usr/java/packages/lib/i386:/usr/lib/jni:/lib:/usr/lib
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-6-openjdk/jre/lib/i386/client/libvcsFPClient.so: /usr/lib/jvm/java-6-openjdk/jre/lib/i386/client/libvcsFPClient.so: cannot open shared object file: No such file or directory (Possible cause: can't load ARM-bit .so on a IA 32-bit platform)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at Damn.<clinit>(Damn.java:4)
Could not find the main class: Damn. Program will exit. "
My system Properties are ,

Using ubuntu 10.04 , i686 .
GCC - 4.4.3
Thanks in Advance.
  • In order to collect some information

    What release are you compiling? it could affect if you are compiling GB or ICS, or a different tools used by Froyo.

    Do you ran Java SDK installation process? was it manual process described in next link? or it was using the rpm.bin file?

    https://wiki.ubuntu.com/LucidLynx/ReleaseNotes/Java6Transition

    following "For more help" link

    https://help.ubuntu.com/community/Java

  • Supposing you did a manual Java installation with previously mentioned procedure then you should need to run the commands in next file. Check that correct version and installation path are used, this according to your actual environment and installed version.

    0763.update-alternatives_jdk.txt.tar.gz

    From your log it is using OpenJDK libraries, commands are to redirect used files.

    Previous questions are not needed since those were only for reference to find out about what version is used and to clarify if this procedure could be related or not.

  • You must do a "make clean" or "make clobber" or remove out directory to start from a clean build and set all needed variables according to used procedure.

  • Hi Manuel ,

      Thanks for quick reply.

               I had been migirated to you mentioned environment . Now  My Actual need is to develop an apllication over using the .so file.  When i'm accessing it by java or android application , throws error as i already mentioned in my previous post. I'll use this application on ICS , Beaglebone. 

    Thanks a lot.  

  • Sangili;

    ok, for what I understood you are working in a project to create a .so file to be loaded from either Java or Android systems (this like generating a multi-platform .so, I can think you refer to a library to use it in both systems with its respective compilation environments, the other option is that you are referring to use Java or Android application as accessing it from .java inside a Android environment and Android application about .apk file.

    I have next questions,

    After searching for the library in JDK directory for OpenJDK this library is not there,

    1. are you adding some special Java library/feature to use in your code? there are some other packages that are not include in standard Java SDK and you need to download them and integrate them to your actual directory structure prior development,

    2. or it is the generated library that is not found? you posted it is in build process when you get this message, the other post shows that it is not running.

    then it is not specified what environment you are using,(next questions are to get full picture, could not be related to actual issue with .so, or not that directly related)

    3. Are you using Android SDK and/or Android NDK + Eclipse + Android Plugin?

    4. Are you building from inside Android File System? or using external environment?

    in ICS it compiles using Java for 64 bits,

    5. is your Ubuntu 10.10 i686 for 64bits? or you are using 32 bits modification to build ICS?

    6. Java needs to use correct version too in order to be use by ICS, in your case it is for i386 by what log shows,

    7. in case you are using a Android File System, which one are you using?

    8. Are you doing a simple .so file? or do you have a simple .so library already working?

    and if your issue is not related to any of the question please mention it and provide some more information about actual configuration and uses.

  • Hi Manuel ,

    I explain my project brief. we're going to make a bio-metric system device by using android platform. There is  my part to developing API. For that we had some .SO files(related to sensor's) , which have few major functions. I have to use those function in my android application project. When i'm trying to access the .SO files functions it throws following errors ,

    07-20 16:44:01.220: E/Trace(698): error opening trace file: No such file or directory (2)
    07-20 16:44:01.580: W/dalvikvm(698): No implementation found for native Lcom/example/nativ/MainActivity;.vcsClientCreate:(Ljava/lang/String;)Ljava/lang/String;
    07-20 16:44:01.590: W/dalvikvm(698): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
    07-20 16:44:01.620: E/AndroidRuntime(698): FATAL EXCEPTION: main
    07-20 16:44:01.620: E/AndroidRuntime(698): java.lang.UnsatisfiedLinkError: Native method not found: com.example.nativ.MainActivity.vcsClientCreate:(Ljava/lang/String;)Ljava/lang/String;
    07-20 16:44:01.620: E/AndroidRuntime(698): at com.example.nativ.MainActivity.vcsClientCreate(Native Method)
    07-20 16:44:01.620: E/AndroidRuntime(698): at com.example.nativ.MainActivity.onCreate(MainActivity.java:19)
    07-20 16:44:01.620: E/AndroidRuntime(698): at android.app.Activity.performCreate(Activity.java:5008)
    07-20 16:44:01.620: E/AndroidRuntime(698): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
    07-20 16:44:01.620: E/AndroidRuntime(698): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
    07-20 16:44:01.620: E/AndroidRuntime(698): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
    07-20 16:44:01.620: E/AndroidRuntime(698): at android.app.ActivityThread.access$600(ActivityThread.java:130)
    07-20 16:44:01.620: E/AndroidRuntime(698): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
    07-20 16:44:01.620: E/AndroidRuntime(698): at android.os.Handler.dispatchMessage(Handler.java:99)
    07-20 16:44:01.620: E/AndroidRuntime(698): at android.os.Looper.loop(Looper.java:137)
    07-20 16:44:01.620: E/AndroidRuntime(698): at android.app.ActivityThread.main(ActivityThread.java:4745)
    07-20 16:44:01.620: E/AndroidRuntime(698): at java.lang.reflect.Method.invokeNative(Native Method)
    07-20 16:44:01.620: E/AndroidRuntime(698): at java.lang.reflect.Method.invoke(Method.java:511)
    07-20 16:44:01.620: E/AndroidRuntime(698): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    07-20 16:44:01.620: E/AndroidRuntime(698): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    07-20 16:44:01.620: E/AndroidRuntime(698): at dalvik.system.NativeStart.main(Native Method)

    system Properties are :

            -Using Eclipse juno 

            - Android - NDK - r8

           - Android - SDK - 20

           - Using java-6-openJDK

           - Using ubuntu 10.04 - i686, 32-bit.(That .so file has build in 32 bit platform)

           - GCC version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) 

    .SO file Info:

    /home/marudham/libvcsFPClient.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped

    So it was build in above format.

    Here my questions are ,

    1) Is possible to view Function types and Arguments from .SO ?

    2) I've tried to load that .So file in both java and c project , but i couldn't .

    3) How to call the function as well as use the output of the function from .SO ?

    Thanks a lot.


  • About:

    1) you can try nm from binutils, it shows symbols, other way consult header files for that library.

    2) you can find examples of how to load a library in next posts, both Native binary or .apk application

    http://e2e.ti.com/support/embedded/android/f/509/p/190609/683982.aspx#683982

    3) you can find examples of how to call function in the examples located in Android SDK, Android NDK.

    From $MYDROID build files I read that there is a check for the Java version, it can affect not using the recommended version in build instructions, you need to check that.

    and try first running with root user your code this to discard it is an permission issue, then you must need to add all the code to register the sensors and add correct permission.

  • Hi manuel,

                  THank's a lot. It was very helpfull. But i couldn't read the function types and arguments from the "libvcsFPClient.so" file. By using the ' nm ' it gives only the name of the function and symbols. Otherwise  , how to extract header files from the .SO. 

    That .SO file has fully developed in c language.

  • For what I know possibly only when compiling with -g option some extra information is added to the binary or library.

    There are some more options to try in binutils package like ranlib or objdump and check if it gives some extra information.

    And you could check the header files then see the function definition, if it is a development package then it must have the include directive or a header file.

  • Sangili;

    If any of previous posts answers your questions please verify the post that does it, if you have more questions not related to initial post create a new post.

    Thank you.