HI Thanks for the reply..
here is my Android.mk :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#LOCAL_LDLIBS := -llog
LOCAL_MODULE := testEngine
LOCAL_SRC_FILES := engine.c cpu.c IO.c memory.c
# No special compiler flags.
LOCAL_CFLAGS += -fno-builtin-printf -static -O3 -DCORE_FREQ=800 -DBAREMETAL -DPMU_CCNT_V7
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
include $(BUILD_SHARED_LIBRARY)
So you mean to say instead of putting engine.c IO.c memory.c i should mention the objct file for each and the LOCAL_MODULE equal to the final library like this :
LOCAL_MODULE := testEngine
LOCAL_SRC_FILES := engine.o cpu.o IO.o memory.o
I will try and post the results ...!!
Thanks again for the reply !!
Rgds,
-J
"..pain is temporary.....quitting lasts forever......"
2011/6/29 Enrique Ocaña González <eoc...@igalia.com>On Martes, 28 de Junio de 2011 23:27:31 Jessica escribió:
Are you sure that the library is being included in the APK? (unzip -l
> and placed it under the same folder where ndk-build was creating
> the .so file that is libs/armeabi> but when i am i trying to load the
> libary i am getting this error by
>
> doing the logcat
>
> D/dalvikvm(17719): Trying to load lib /data/data/<package name>/lib/
> libTestengine.so 0x43e45c48
>
> I/dalvikvm(17719): Unable to dlopen(<package name>/lib/
> libTestengine.so): Cannot load library: link_image[1995]: failed to
> link libTestengine.so
bin/*.apk)
If you use Eclipse, clean your project, rebuild it and look into the APK
again. If it's still not there, maybe you need to explicitly create some rules
to include the library as an external precompiled library:
jni/Application.mk ------
...
APP_MODULES := testengine
...
jni/Android.mk ----------
...
include $(CLEAR_VARS)
LOCAL_MODULE := testengine
LOCAL_SRC_FILES := relative/path/to/libTestengine.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/relative/path/to/include/dir
include $(PREBUILT_SHARED_LIBRARY)
...
With these declarations, ndk-build will copy the library from its original
place to libs and obj and the Eclipse build scripts will include it in the
APK.
--
Enrique Ocaña
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
....include $(CLEAR_VARS)LOCAL_MODULE := libfoo_prebuiltLOCAL_SRC_FILES := /path/to/libfoo.ainclude $(PREBUILT_STATIC_LIBRARY)...
....LOCAL_STATIC_LIBRARIES := libfoo_prebuiltinclude $(BUILD_SHARED_LIBRARY)
--Saurabh
"..pain is temporary.....quitting lasts forever......"
On Thu, Jun 30, 2011 at 10:43 AM, s.rawat <imsaura...@gmail.com> wrote:
HI Thanks for the reply..
here is my Android.mk :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#LOCAL_LDLIBS := -llog
LOCAL_MODULE := testEngine
LOCAL_SRC_FILES := engine.c cpu.c IO.c memory.c
# No special compiler flags.
LOCAL_CFLAGS += -fno-builtin-printf -static -O3 -DCORE_FREQ=800 -DBAREMETAL -DPMU_CCNT_V7
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
include $(BUILD_SHARED_LIBRARY)
So you mean to say instead of putting engine.c IO.c memory.c i should mention the objct file for each and the LOCAL_MODULE equal to the final library like this :
LOCAL_MODULE := testEngine
LOCAL_SRC_FILES := engine.o cpu.o IO.o memory.o
I will try and post the results ...!!
Thanks again for the reply !!
Rgds,
-Saurabh
"..pain is temporary.....quitting lasts forever......"
Forwarded conversation------------------------
Subject: Linking different object files created from crosstool with the current shared library created from ndk-build
----------
From: David Turner <di...@android.com>
Date: Thu, Jun 30, 2011 at 7:24 PM
Archive your object files into a library (e.g. libfoo.a)Then declare a prebuilt static library in your Android.mk, as in....include $(CLEAR_VARS)LOCAL_MODULE := libfoo_prebuiltLOCAL_SRC_FILES := /path/to/libfoo.ainclude $(PREBUILT_STATIC_LIBRARY)...Then later reference it in the LOCAL_STATIC_LIBRARIES line of your main module....LOCAL_STATIC_LIBRARIES := libfoo_prebuiltinclude $(BUILD_SHARED_LIBRARY)Read docs/PREBUILT.html for more details.Of course, the link is likely to fail if you use a cross-toolchain that doesn't support Android properly.
HI David ,
Thanks for the reply
>
- Does this means object files being created from the cross compiler may or may not get linked with the shared library created with the ndk-build(ndk5rc) always.What kind of proper support is needed from the tool chain?
The reason why I am using the cross tool is that certain code (assembly routines) needs to be necessarily compiled by the tool chain but since file1 functionality above is arch independent , we are partially using android ndk-build(for shared library) and partially via tool chain (file2 and 3)but both the shared libarary(from ndk) and the object files created from the tool chain needs to be linked together to make one single .so file which can be loaded and called via jni calls.UNfortunately this is not happening.(dont know how to link them, until you proposed the above way, will check on this)
Rgds,
--Saurabh
--Saurabh-Saurabh
----------From: s.rawat <imsaura...@gmail.com>Date: Thu, Jun 30, 2011 at 11:33 PM
To: "saurabh.rawat" <saurab...@nexbits.com>
my-tool-chain-readelf
libs/armeabi-v7a/libtestEngine.so -ld
Elf file type is DYN (Shared object file)
Entry point 0x10e0
There are 5 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr
PhysAddr FileSiz MemSiz
Flg Align
EXIDX 0x0038c8 0x000038c8 0x000038c8
0x000b8 0x000b8 R 0x4
LOAD 0x000000 0x00000000 0x00000000
0x03980 0x03980 R E 0x1000
LOAD 0x003980 0x00004980 0x00004980
0x00140 0x0014c RW 0x1000
DYNAMIC 0x003980 0x00004980 0x00004980 0x000d0
0x000d0 RW 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000
0x00000 RW 0x4
Section to Segment mapping:
Segment Sections...
00
.ARM.exidx
01
.hash .dynsym .dynstr .rel.dyn .rel.plt .plt .text .rodata .ARM.extab
.ARM.exidx
02
.dynamic .got .bss
03
.dynamic
04
Dynamic section at offset 0x3980 contains 22 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libsqlite3.so.0]
0x00000001 (NEEDED) Shared library:
[libc.so]
0x00000001 (NEEDED) Shared library:
[libstdc++.so]
0x00000001 (NEEDED) Shared library:
[libm.so]
0x00000001 (NEEDED) Shared library:
[liblog.so]
0x00000001 (NEEDED) Shared library:
[libdl.so]
0x0000000e (SONAME) Library soname:
[libtestEngine.so]
0x00000010 (SYMBOLIC) 0x0
0x00000004 (HASH) 0xd4
0x00000005 (STRTAB) 0x9a4
0x00000006 (SYMTAB) 0x374
0x0000000a (STRSZ) 1378 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000003 (PLTGOT) 0x4a50
0x00000002 (PLTRELSZ) 168 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0xf28
0x00000011 (REL) 0xf08
0x00000012 (RELSZ) 32 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffa (RELCOUNT) 2
0x00000000 (NULL) 0x0
Rgds,
Saurabh