Hi,
I used the following commands to create shared library
arm-none-linux-gnueabi-gcc -fpic -c sample.c
arm-none-linux-gnueabi-ld -T armelf_linux_eabi.xsc -shared -o
libmylib.so sample.o
Now it is working.
But problem is
If iam using any c functions like fgets,strcpy
It is unable to load my shared library
And the logcat is showing as
06-03 11:01:17.283: INFO/dalvikvm(226): Unable to dlopen(/data/data/
sct.widget/lib/libmylib.so): Cannot load library:
reloc_library[1244]:    30 cannot locate 'fgets'...

I understand that while creating  libmylib.so we need to give support
of glibc that means we need to link it with our shared library
How can i do this please help me
Regards,
karteek.


On Jun 1, 8:01 pm, karteek <kartee...@gmail.com> wrote:
> mah thanks for your reply
> 1 I checked in /data/data/mypackage/libs
>   my library is present in the above folder
> Second aproach you suggested me is
> I am able to work with ndk tools
> I observed both libraries that mean one my build and second one is
> through ndk tools
> i used nm tool to see what is in it.
> But i did not understand any thing i am pure in this terminology
> i am pasting the nm tool out put can u suggest any thing
> Thanks in advance.
> # nm libmylib.so //using arm tool chain
> 000003d8 t $a
> 000003a0 t $a
> 000004e8 t $a
> 000003a8 t $a
> 000004ec t $a
> 000003fc t $a
> 00000450 t $a
> 00000494 t $a
> 000003ac t $a
> 000003c0 t $a
> 000003f4 t $d
> 00008620 d $d
> 00000440 t $d
> 00008510 t $d
> 00000488 t $d
> 0000850c t $d
> 00008624 b $d
> 000004f0 r $d
> 000004e0 t $d
> 00000508 r $d
> 00008514 d $d
> 000003bc t $d
> 00000494 T Java_sct_notification_NotificationJNIActivity_getStrings
> 00008518 a _DYNAMIC
> 00008600 a _GLOBAL_OFFSET_TABLE_
>          w _Jv_RegisterClasses
> 00000508 r __FRAME_END__
> 00008514 d __JCR_END__
> 00008514 d __JCR_LIST__
> 00008628 A __bss_end__
> 00008624 A __bss_start
> 00008624 A __bss_start__
>          w __cxa_finalize@@GLIBC_2.4
> 000003fc t __do_global_dtors_aux
> 00008510 t __do_global_dtors_aux_fini_array_entry
> 00008620 d __dso_handle
> 00008628 A __end__
> 00000508 A __exidx_end
> 00000508 A __exidx_start
> 0000850c t __frame_dummy_init_array_entry
>          w __gmon_start__
> 00008628 A _bss_end__
> 00008624 A _edata
> 00008628 A _end
> 000004e8 T _fini
> 000003a0 T _init
> 000003d8 t call_gmon_start
> 00008624 b completed.6049
> 00000450 t frame_dummy
>
> Second one
> # nm libsctlib.so
> 00000b94 t $a
> 00000ba8 t $a
> 00000bf4 t $a
> 00000c1c t $a
> 00000c68 t $a
> 00000c94 t $a
> 00000cac t $a
> 00000d38 t $a
> 00000d40 t $a
> 00000d44 t $a
> 00000d64 t $a
> 00001114 t $a
> 0000111c t $a
> 00001124 t $a
> 0000112c t $a
> 00001260 t $a
> 000012cc t $a
> 00001394 t $a
> 000014b0 t $a
> 000014cc t $a
> 00001524 t $a
> 000015c8 t $a
> 000015e8 t $a
> 00001654 t $a
> 00001684 t $a
> 000019c0 t $a
> 00001b68 t $a
> 00001bc0 t $a
> 00001bc8 t $a
> 00001bd0 t $a
> 00001bf8 t $a
> 00001c00 t $a
> 00001c1c t $a
> 00001c2c t $a
> 00001fa8 t $a
> 00000b24 t $a
> 00000b38 t $a
> 00000b8c t $d
> 00001110 t $d
> 00001248 t $d
> 00001670 t $d
> 00001fa4 t $d
> 00000b34 t $d
> 00000b74 t $t
> 00000b74 t $t
> 00000b75 T Java_sct_notification_NotificationJNIActivity_getStrings
> 00003128 a _DYNAMIC
> 000031e8 a _GLOBAL_OFFSET_TABLE_
> 00001b44 T _Unwind_Backtrace
> 00000d40 T _Unwind_Complete
> 00000d44 T _Unwind_DeleteException
> 00001b20 T _Unwind_ForcedUnwind
> 00000d38 T _Unwind_GetCFA
> 00001bc8 T _Unwind_GetDataRelBase
> 00000bf4 t _Unwind_GetGR
> 00001bd0 t _Unwind_GetGR
> 00001c00 T _Unwind_GetLanguageSpecificData
> 00001c1c T _Unwind_GetRegionStart
> 00001bc0 T _Unwind_GetTextRelBase
> 00001ab4 T _Unwind_RaiseException
> 00001ad8 T _Unwind_Resume
> 00001afc T _Unwind_Resume_or_Rethrow
> 00000c68 t _Unwind_SetGR
> 00000ba8 T _Unwind_VRS_Get
> 00001654 T _Unwind_VRS_Pop
> 00000c1c T _Unwind_VRS_Set
> 00000b94 t _Unwind_decode_target2
> 00001b44 T ___Unwind_Backtrace
> 00001b20 T ___Unwind_ForcedUnwind
> 00001ab4 T ___Unwind_RaiseException
> 00001ad8 T ___Unwind_Resume
> 00001afc T ___Unwind_Resume_or_Rethrow
> 00001124 T __aeabi_unwind_cpp_pr0
> 0000111c W __aeabi_unwind_cpp_pr1
> 00001114 W __aeabi_unwind_cpp_pr2
> 00003208 A __bss_end__
> 00003208 A __bss_start
> 00003208 A __bss_start__
>          w __cxa_begin_cleanup
>          w __cxa_call_unexpected
>          w __cxa_type_match
> 00003208 D __data_start
> 00003208 A __end__
> 00002128 A __exidx_end
> 00002018 A __exidx_start
> 000012cc T __gnu_Unwind_Backtrace
>          w __gnu_Unwind_Find_exidx
> 000014b0 T __gnu_Unwind_ForcedUnwind
> 00001524 T __gnu_Unwind_RaiseException
> 000019d4 T __gnu_Unwind_Restore_VFP
> 000019e4 T __gnu_Unwind_Restore_VFP_D
> 000019f4 T __gnu_Unwind_Restore_VFP_D_16_to_31
> 00001a8c T __gnu_Unwind_Restore_WMMXC
> 00001a04 T __gnu_Unwind_Restore_WMMXD
> 000015e8 T __gnu_Unwind_Resume
> 000015c8 T __gnu_Unwind_Resume_or_Rethrow
> 000019dc T __gnu_Unwind_Save_VFP
> 000019ec T __gnu_Unwind_Save_VFP_D
> 000019fc T __gnu_Unwind_Save_VFP_D_16_to_31
> 00001aa0 T __gnu_Unwind_Save_WMMXC
> 00001a48 T __gnu_Unwind_Save_WMMXD
> 00001c2c T __gnu_unwind_execute
> 00001fa8 T __gnu_unwind_frame
> 00000d64 t __gnu_unwind_pr_common
> 000019c0 T __restore_core_regs
> 00003208 A _bss_end__
> 00003208 A _edata
> 00003208 A _end
> 00080000 N _stack
>          U abort
> 0000112c t get_eit_entry
>          U memcpy
> 00001b68 t next_unwind_byte
> 000019c0 T restore_core_regs
> 00001260 t restore_non_core_regs
> 00000cac t search_EIT_table
> 00000c94 t selfrel_offset31
> 00001bf8 t unwind_UCB_from_context
> 000014cc t unwind_phase2
> 00001394 t unwind_phase2_forced
>
> Regards,
> karteek
>
> On Jun 1, 4:32 pm, mah <m...@heilpern.com> wrote:
>
> > From what I've seen, the "library not found" error doesn't only occur
> > if the library cannot be found, however your first step now should
> > probably be to see if it should be found... open an "adb shell" to
> > your platform, and change directory to /data/data/
> > your.package.name.here. Does the lib directory exist? If so, is
> > your .so inside it? If the answer to either of these is no, you're not
> > including the library in the package correctly.
>
> > If the file does exist, the failure to load is based on the exported
> > contents of the library. In this case, you'll want to work with one of
> > the sample libraries that come with the NDK and compare it to your own
> > to figure out what's missing.
>
> > On Jun 1, 4:28 am, karteek <kartee...@gmail.com> wrote:
>
> > > You are wright.
> > > Now i compiled with  following commands
> > > arm-none-linux-gnueabi-gcc -fPIC -c sample.c -o sample.o
> > > arm-none-linux-gnueabi-gcc -shared -Wl,-soname,libmylib.so -o
> > > libmylib.so sample.o
>
> > > even though iam getting the same problem
>
> > > On May 29, 2:34 am, mah <m...@heilpern.com> wrote:
>
> > > > That would likely mean you've compiled your library using an x86
> > > > compiler. That will not run on an ARM processor.
>
> > > > You do not have to use the Android makefile or build system to build
> > > > your library, but you do need to use the compiler that comes with the
> > > > NDK.
>
> > > > On May 27, 3:05 am, karteek <kartee...@gmail.com> wrote:
>
> > > > > > How did you compile the library if you didn't use the NDK?.
>
> > > > > I compiled using the following commands
> > > > > cc -c -fPIC mycfile.c -o mycfile.o
> > > > > cc -o libmylib.so -shared -Wl,-soname,libmy.so mycfile.o
>
> > > > > On May 27, 11:03 am, David Turner <di...@android.com> wrote:
>
> > > > > > How did you compile the library if you didn't use the NDK?. There 
> > > > > > are great
> > > > > > chances that what you generated is not a valid ARM ELF binary that 
> > > > > > can be
> > > > > > loaded on Android.
>
> > > > > > On Tue, May 25, 2010 at 6:31 AM, Karteek N <kartee...@gmail.com> 
> > > > > > wrote:
> > > > > > > Hi all,
> > > > > > > I have gone through android ndk tutorials.
> > > > > > > But i am little confusing in Android.mk file as well as 
> > > > > > > Application.mk file
> > > > > > > so instead of that i used the following approach
> > > > > > > I created a Test.java file which is having one native method.
> > > > > > > i added the static{
>
> > > > > > > System.loadLibrary("mylib");
> > > > > > > }
> > > > > > > By using javah -jni i generated Test.h and using that decleration 
> > > > > > > i
> > > > > > > implemented  a c file
> > > > > > > And i compiled c file and generated the libmylib.so library.
> > > > > > > But now my question is how to add this shared library to my 
> > > > > > > android
> > > > > > > application
> > > > > > > I followed 2 approaches but all throwing exception that Library 
> > > > > > > mylib not
> > > > > > > founed.
> > > > > > > 1 In eclipse BuildPath->ConfigurebuildPath->Android2.1->native 
> > > > > > > given the
> > > > > > > path of my shared library
> > > > > > > 2 I copied shared library to /data/data/myprojectpackagenae/lib/
> > > > > > >   and used the statement in my code as
> > > > > > >    System.load("/data/data/mypackagename/lib/libmylib.so");
>
> > > > > > > In above two cases it is throwing same exception
>
> > > > > > > Where iam wrong?
> > > > > > > Is it  procedure is wright?
> > > > > > > Please help me
>
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the Google
> > > > > > > Groups "Android Developers" group.
> > > > > > > To post to this group, send email to 
> > > > > > > android-developers@googlegroups.com
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to