Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libjpeg-turbo for android

I need libjpeg-turbo for android ndk. Did anyone managed to compile it as .a (static) lib? I have tried a few times, but it gave me a lot of errors only.

like image 354
KoVadim Avatar asked Sep 04 '12 09:09

KoVadim


1 Answers

Install Android NDK. Following instructions were verified with r8b, older versions may have problems, I don't know.

Get the Android sources for libjpeg-turbo from Benjamin Gaignard:

git clone git://git.linaro.org/people/tomgall/libjpeg-turbo/libjpeg-turbo.git -b linaro-android

In the libjpeg-turbo directory created by git, edit file Android.mk: after line 70, LOCAL_MODULE := libjpeg, add the following:

ifeq ($(notdir $(MAKECMDGOALS)),libjpeg.a)
  LOCAL_SRC_FILES +=  $(libsimd_SOURCES_DIST)
  include $(BUILD_STATIC_LIBRARY)
  include $(CLEAR_VARS)
  LOCAL_MODULE := dummy
endif

Run ndk-build:

ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk obj/local/armeabi/libjpeg.a

Profit!

PS: You may want the armeabi-v7a version:

ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk APP_ABI=armeabi-v7a obj/local/armeabi-v7a/libjpeg.a

Or compile for ARM, to improve performance, add to command line:

LOCAL_ARM_MODE=arm

If your target has NEON support, add to command line:

LOCAL_ARM_NEON=true ARCH_ARM_HAVE_NEON=true

UPDATE: to get it work with Android NDK r15 and later, remove all references to libcutils from Android.mk.

like image 77
Alex Cohn Avatar answered Nov 16 '22 00:11

Alex Cohn