A
A
Anton Nadtoka2016-11-28 16:51:08
Android
Anton Nadtoka, 2016-11-28 16:51:08

How to add ZLIB support to Android Studio ( C++ )?

I am using Android Studio 2.2.2, I want to make a library for an application in which I will use libpng. LibPng added and built but not linking - can't find zlib, does it need to be manually added or is it available out of the box in the NDK?
As known to use the CMake builder, I added the following lines:
find_library(
log-lib
log
zlib
)
target_link_libraries(
android
lz
log
)
and I end up with an error when compiling:

CMakeFiles/applib.dir/Users/antondev/Projects/applib/applib/libs/libpng/pngwtran.c.o CMakeFiles/applib.dir/Users/antondev/Projects/applib/applib/libs/libpng/pngwutil.c.o  -landroid -llog -llz -lEGL -lGLESv2 -lm "/Users/antondev/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/libgnustl_static.a" && :
  /Users/antondev/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/mips64el-linux-android/4.9.x/../../../../mips64el-linux-android/bin/ld: cannot find -llz
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.

how to add zlib correctly? Can't find a solution. Although it is listed in FindZLIB in CMake modules.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Shatunov, 2016-11-28
@engune

cannot find -llz
Memory tells me that it's not "-llz", but "-lz". :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question