How to compile libjpeg?

3,519 views
Skip to first unread message

tueda

unread,
May 19, 2011, 9:08:56 AM5/19/11
to android-ndk
When compiling libjpeg,

$ git clone git://android.git.kernel.org/platform/external/jpeg
$ cd jpeg
$ mkdir jni
$ cp * jni
$ ndk-build
(compiling *.c here...)
: error: cutils/ashmem.h: No such file or directory

Compilation was stopped.
What is the cutils/ashmem.h?
Why not found?
And how to compile libjpeg?

alan

unread,
May 19, 2011, 9:14:24 AM5/19/11
to andro...@googlegroups.com
it fails because you are trying to build a platform library with the ndk rather than the platform sdk. I'm sure someone has posted instructions for building libjpeg on this group

tueda

unread,
May 19, 2011, 9:56:14 AM5/19/11
to android-ndk

I can't find any useful information in this group.
Because libjpeg is a very common library, I expect someone may already
ported it to Android-NDK.
Where can I download it from, and how to compile it?
Any information welcome.

Tim Mensch

unread,
May 19, 2011, 2:09:45 PM5/19/11
to andro...@googlegroups.com
I'm no longer using libjpeg, but when I was, this was my Android.mk, which lived right above a folder named "jpeg" which contains the Android platform source files. In general I found it built with no issues, if I remember correctly. Mine doesn't have an ashmem.h, for example. Just to simplify things I've put a zip of the whole folder here:

http://rc2.rechargegames.com/jpeg.zip

I disclaim all license to that folder. Do with it what you like.


------- Android.mk
LOCAL_PATH:= $(call my-dir)/jpeg
include $(CLEAR_VARS)

LOCAL_ARM_MODE := arm

LOCAL_SRC_FILES := \
        jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \
        jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \
        jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \
        jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \
        jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \
        jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \
        jfdctint.c jidctflt.c jidctred.c jquant1.c \
        jquant2.c jutils.c jmemmgr.c \
        jmem-android.c

# the assembler is only for the ARM version, don't break the Linux sim
ifneq ($(TARGET_ARCH),arm)
ANDROID_JPEG_NO_ASSEMBLER := true
endif

# temp fix until we understand why this broke cnn.com
#ANDROID_JPEG_NO_ASSEMBLER := true

ifeq ($(strip $(ANDROID_JPEG_NO_ASSEMBLER)),true)
LOCAL_SRC_FILES += jidctint.c jidctfst.c
else
LOCAL_SRC_FILES += jidctint.c jidctfst.S
endif

LOCAL_CFLAGS += -DAVOID_TABLES 
LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays
#LOCAL_CFLAGS += -march=armv6j

LOCAL_MODULE:= libjpeg

include $(BUILD_STATIC_LIBRARY)


tueda

unread,
May 20, 2011, 10:48:07 PM5/20/11
to android-ndk

I am happy to say, it works fine!
Thank you for your help.

By the way, I hope "Android native code repository" will be back.
https://groups.google.com/group/android-ndk/browse_thread/thread/3ecd5159bdb5cd1c

Rajesh

unread,
Nov 28, 2012, 4:40:28 AM11/28/12
to andro...@googlegroups.com
Hi ,



While using libjpeg in Android Native NDK i am facing the following issues. 

i have used the code from following link nad have used your zip file from above post. 


Please advice me . 

/obj/local/armeabi/objs/gsnap/gsnap.o: In function `snap2jpg':
/jni/gsnap.c:167: undefined reference to `jpeg_std_error'
/jni/gsnap.c:168: undefined reference to `jpeg_CreateCompress'
/jni/gsnap.c:177: undefined reference to `jpeg_stdio_dest'
/jni/gsnap.c:182: undefined reference to `jpeg_set_defaults'
/jni/gsnap.c:183: undefined reference to `jpeg_set_quality'
/jni/gsnap.c:184: undefined reference to `jpeg_start_compress'
/jni/gsnap.c:202: undefined reference to `jpeg_write_scanlines'
/jni/gsnap.c:205: undefined reference to `jpeg_finish_compress'
/jni/gsnap.c:208: undefined reference to `jpeg_destroy_compress'



Reply all
Reply to author
Forward
0 new messages