Cannot link to zlib correctly

2,205 views
Skip to first unread message

Todd

unread,
Jun 26, 2009, 4:29:02 AM6/26/09
to android-ndk
I am using the official Android NDK for my project.
By NDK docs, zlib is a stable library which we can use.

I have add the following line in Android.mk to link to zlib.so

LOCAL_LDLIBS := -lz

But it comes out some error, the output error messages are:

/cygdrive/c/android-ndk-1.5_r1/build/prebuilt/windows/arm-eabi-4.2.1/
bin/../lib/
gcc/arm-eabi/4.2.1/../../../../arm-eabi/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/apps/AndroidTV/android-1.5-arm/libnativedecoder.so]
Error 1

How can I link to zlib correctly? Any information is appreciated :D

kk

unread,
Jun 30, 2009, 12:33:58 PM6/30/09
to android-ndk
I have the same exact issue with log library :


make APP=testapp V=1
Android NDK: Building for application 'testapp'
Compile thumb : testapp-jni <= sources/testapp-jni/testapp-jni.c
build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-gcc -Ibuild/
platforms/android-1.5/arch-arm/usr/include -march=armv5te -
mtune=xscale -msoft-float -fpic -mthumb-interwork -ffunction-sections -
funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -
D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Isources/
testapp-jni -DANDROID -O2 -DNDEBUG -g -c -MMD -MP -MF out/apps/
testapp/android-1.5-arm/objs/testapp-jni/testapp-jni.o.d.tmp sources/
testapp-jni/testapp-jni.c -o out/apps/testapp/android-1.5-arm/objs/
testapp-jni/testapp-jni.o
build/core/mkdeps.sh out/apps/testapp/android-1.5-arm/objs/testapp-jni/
testapp-jni.o out/apps/testapp/android-1.5-arm/objs/testapp-jni/
testapp-jni.o.d.tmp out/apps/testapp/android-1.5-arm/objs/testapp-jni/
testapp-jni.o.d
SharedLibrary : libtestapp-jni.so
build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-gcc -nostdlib -
Wl,-soname,libtestapp-jni.so -Wl,-shared,-Bsymbolic out/apps/testapp/
android-1.5-arm/objs/testapp-jni/testapp-jni.o -Wl,--whole-archive -
Wl,--no-whole-archive
build/platforms/android-1.5/arch-arm/usr/lib/libc.so build/platforms/
android-1.5/arch-arm/usr/lib/libstdc++.so build/platforms/android-1.5/
arch-arm/usr/lib/libm.so -Wl,--no-undefined -llog -Wl,-rpath-
link=build/platforms/android-1.5/arch-arm/usr/lib /usr/lib/android-
ndk-1.5_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/../lib/gcc/arm-
eabi/4.2.1/interwork/libgcc.a -o out/apps/testapp/android-1.5-arm/
libtestapp-jni.so

/usr/lib/android-ndk-1.5_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/
bin/../lib/gcc/arm-eabi/4.2.1/../../../../arm-eabi/bin/ld: cannot find
-llog

collect2: ld returned 1 exit status
make: *** [out/apps/testapp/android-1.5-arm/libtestapp-jni.so] Error 1

David Turner

unread,
Jun 30, 2009, 2:29:05 PM6/30/09
to andro...@googlegroups.com
Yes, sorry about that but this is really a bug in the NDK build scripts.
Right now, you can replace:

LOCAL_LDLIBS := -lz

with

LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lz

sorry about that, this will be fix in the next NDK release.

k kruups

unread,
Jul 1, 2009, 11:12:36 AM7/1/09
to andro...@googlegroups.com

Hi David,

Thanks I used the workaround, works fine.

KK

On Jul 1, 2009 3:29 AM, "David Turner" <di...@android.com> wrote:

Yes, sorry about that but this is really a bug in the NDK build scripts.
Right now, you can replace:

LOCAL_LDLIBS := -lz

with

LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lz

sorry about that, this will be fix in the next NDK release.

On Tue, Jun 30, 2009 at 6:33 PM, kk <kkr...@gmail.com> wrote: > > > I have the same exact issue w...

Reply all
Reply to author
Forward
0 new messages