Friday, March 11, 2016

Building webp library (libwebp-0.4.4) using Android NDK

My setup:
  • OpenSuse Linux Leap 42.1.20151028 x86_64 (64Bit), AMD Athlon X2
  • Android NDK r10e­rc4 (64­bit). Directory name android­ndk­r10e­linux
  • Terminal / Bash shell. On Windows one needs to install binutils, development environment. Just install CodeBlocks windows or other such compiler. They contain most of needed tools.

The title of this post can also be "compile libwebp-0.4.4.tar.gz without Android Studio or without Eclipse". Compile library using ndk-build without android project.


To compile a jni code Android NDK requires a layout of files. We will blind NDK to believe there is an android project and it will compile. Since libwebp (atleast 0.4.4) already contains Android.mk its very easy to compile it.

To create blind NDK assuming there is Android project follow these steps:
  • Create a directory webp. Create jni directory inside it. Extract libweb inside jni. path to libweb Android. mk must be webp/jni/libwebp-0.4.4/Android.mk
  • Create Android.mk & Application.mk files inside jni.
  • Create AndroidManifest.xml above jni directory.


Contents of files:


webp/jni/Android.mk

include  $(call all-subdir-makefiles)


webp/jni/Application.mk

APP_ABI := armeabi-v7a
APP_PLATFORM := android-8
APP_OPTIM := release




webp/AndroidManifest.xml
File content is saved in linked file due to xml getting stripped in this blog.

Link: http://txt.do/5vik0 or http://textuploader.com/5vik0 




Building:
Ensure you have NDK in path environment. It means you can run ndk-build without giving full path. If not then add it in path variable Or simply run /fullpath/ndk-build script from webp/ directory. it will start building webp.


After build is complete the binary files are copied into webp/libs and webp/obj/local. libwebp.a is present in obj/local/armeabi-v7a directory.



Below is the log from my system:


bindesh@linux-k2zc:/mnt/work/work/programming/Android/00_libraries/libwebp/libwebp-0.4.4> ndk-build
[armeabi-v7a] Compile thumb  : cwebp <= cwebp.c
[armeabi-v7a] Compile thumb  : cwebp <= jpegdec.c
[armeabi-v7a] Compile thumb  : cwebp <= metadata.c
[armeabi-v7a] Compile thumb  : cwebp <= pngdec.c
[armeabi-v7a] Compile thumb  : cwebp <= tiffdec.c
[armeabi-v7a] Compile thumb  : cwebp <= webpdec.c
[armeabi-v7a] Compile thumb  : example_util <= example_util.c
[armeabi-v7a] StaticLibrary  : libexample_util.a
[armeabi-v7a] Compile arm    : webp <= enc.c
[armeabi-v7a] Compile arm    : webp <= enc_avx2.c
[armeabi-v7a] Compile arm    : webp <= enc_mips32.c
[armeabi-v7a] Compile arm    : webp <= enc_neon.c
[armeabi-v7a] Compile arm    : webp <= enc_sse2.c
[armeabi-v7a] Compile arm    : webp <= alpha.c
[armeabi-v7a] Compile arm    : webp <= analysis.c
[armeabi-v7a] Compile arm    : webp <= backward_references.c
[armeabi-v7a] Compile arm    : webp <= config.c
[armeabi-v7a] Compile arm    : webp <= cost.c
[armeabi-v7a] Compile arm    : webp <= filter.c
[armeabi-v7a] Compile arm    : webp <= frame.c
[armeabi-v7a] Compile arm    : webp <= histogram.c
[armeabi-v7a] Compile arm    : webp <= iterator.c
[armeabi-v7a] Compile arm    : webp <= picture.c
[armeabi-v7a] Compile arm    : webp <= picture_csp.c
[armeabi-v7a] Compile arm    : webp <= picture_psnr.c
[armeabi-v7a] Compile arm    : webp <= picture_rescale.c
[armeabi-v7a] Compile arm    : webp <= picture_tools.c
[armeabi-v7a] Compile arm    : webp <= quant.c
[armeabi-v7a] Compile arm    : webp <= syntax.c
[armeabi-v7a] Compile arm    : webp <= token.c
[armeabi-v7a] Compile arm    : webp <= tree.c
[armeabi-v7a] Compile arm    : webp <= vp8l.c
[armeabi-v7a] Compile arm    : webp <= webpenc.c
[armeabi-v7a] Compile arm    : webp <= bit_writer.c
[armeabi-v7a] Compile arm    : webp <= huffman_encode.c
[armeabi-v7a] Compile arm    : webp <= quant_levels.c
[armeabi-v7a] StaticLibrary  : libwebp.a
[armeabi-v7a] Compile thumb  : cpufeatures <= cpu-features.c
[armeabi-v7a] StaticLibrary  : libcpufeatures.a
[armeabi-v7a] Compile arm    : webpdecoder_static <= alpha.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= buffer.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= frame.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= idec.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= io.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= quant.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= tree.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= vp8.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= vp8l.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= webp.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= alpha_processing.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= alpha_processing_sse2.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= cpu.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= dec.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= dec_clip_tables.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= dec_mips32.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= dec_neon.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= dec_sse2.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= lossless.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= lossless_mips32.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= lossless_neon.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= lossless_sse2.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= upsampling.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= upsampling_neon.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= upsampling_sse2.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= yuv.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= yuv_mips32.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= yuv_sse2.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= bit_reader.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= color_cache.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= filters.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= huffman.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= quant_levels_dec.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= random.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= rescaler.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= thread.c
[armeabi-v7a] Compile arm    : webpdecoder_static <= utils.c
[armeabi-v7a] StaticLibrary  : libwebpdecoder_static.a
[armeabi-v7a] Executable     : cwebp
[armeabi-v7a] Install        : cwebp => libs/armeabi-v7a/cwebp
[armeabi-v7a] Compile thumb  : dwebp <= dwebp.c
[armeabi-v7a] Executable     : dwebp
[armeabi-v7a] Install        : dwebp => libs/armeabi-v7a/dwebp
[armeabi-v7a] Compile thumb  : webpmux_example <= webpmux.c
[armeabi-v7a] Compile arm    : webpmux <= muxedit.c
[armeabi-v7a] Compile arm    : webpmux <= muxinternal.c
[armeabi-v7a] Compile arm    : webpmux <= muxread.c
[armeabi-v7a] StaticLibrary  : libwebpmux.a
[armeabi-v7a] Executable     : webpmux_example
[armeabi-v7a] Install        : webpmux_example => libs/armeabi-v7a/webpmux_example

No comments: