ndk jpeg library linkage error? (JPEG parameter struct mismatch; library thinks size is 464, caller expects 480)

1,185 views
Skip to first unread message

Kirk A

unread,
Mar 23, 2011, 8:15:49 AM3/23/11
to android-ndk
I'm working on some image processing. Works fine in emulator, but oom
(out of memory) on phone. Therefore, my foray into the NDK. I've
adapted code from external/jpeg/example.c and link out/target/product/
generic/obj/SHARED_LIBRARIES/libjpeg_intermediates/LINKED -ljpeg in
order to open and read the jpeg image captured with Android's camera.

However, in the jpeg code, upon calling the first routine after
opening the file, jpeg_create_decompress(&cinfo), I hit the error
routine and determine that the culprit is error 21, as cited in the
title (JPEG parameter struct mismatch; library thinks size is 464,
caller expects 480).

I honestly don't know where to begin... Please advise.

Thank you,
Kirk

alan

unread,
Mar 23, 2011, 9:14:14 AM3/23/11
to andro...@googlegroups.com
i assume that you are linking to the system jpeg library rather than your own build and that the two libraries are different versions. you must create a new shared library with a different name (e.g. libKirkJpeg.so) or staticly link libjpeg into your shared library. see docs/STABLE-APIS.html for the libraries that you are allowed to use

Kirk A

unread,
Mar 23, 2011, 1:15:51 PM3/23/11
to android-ndk
Why was this thread recently deleted?


I thought that the original was relevant enough, the LOCAL_C_INCLUDES begin with

~/mydroid/external/jpeg

and the LOCAL_LDLIBS includes

-L/home/kmanderson/mydroid/out/target/product/generic/system/lib -ljpeg

Under the Android build (e..g, ~/mydroid), there are no static (.a) versions of jpeg library, only shareable (.so) versions. Web searches on this error seem to suggest that components may be built with different ISO options -- such as the so-called "lossless" jpeg, and several others.

By pointing my ndk_build Android.mk to the Android diistribution's external/jpeg directory, I expected consistency, however my build is still inconsistent.

The Android NDK Stable APIs does not directly address libjpeg. Nor does it address libpng, a static library that I have incorporated and used successfully.

Interestingly, the only other module in the Android distro to call the jpeg_create_decompress(&cinfo) function is ~/mydroid/system/extras/tests/bionic/libc/other/test_jpeg.c -- but this particular test_jpeg.c file is omitted from the Android.mk file in its parent directory.

I'm still investigating other examples in the distro code tree... but this remains a problem for me at the present time.

-Kirk

David Turner

unread,
Mar 23, 2011, 1:25:44 PM3/23/11
to andro...@googlegroups.com, Kirk A
On Wed, Mar 23, 2011 at 6:15 PM, Kirk A <kir...@gmail.com> wrote:
Why was this thread recently deleted?

Nobody deleted it as far as I know.
 
On 23 March 2011 08:15, Kirk A <kir...@gmail.com> wrote:

I thought that the original was relevant enough, the LOCAL_C_INCLUDES begin with

~/mydroid/external/jpeg

and the LOCAL_LDLIBS includes

-L/home/kmanderson/mydroid/out/target/product/generic/system/lib -ljpeg

Under the Android build (e..g, ~/mydroid), there are no static (.a) versions of jpeg library, only shareable (.so) versions. Web searches on this error seem to suggest that components may be built with different ISO options -- such as the so-called "lossless" jpeg, and several others.


The problem is probably that:

a/ the headers under ~/mydroid/external/jpeg do not match the jpeg library on the system
b/ the libjpeg.so library your built does not match the version on the system you're running on (unless you flashed your build on the device)
c/ any combination of the above.
 
By pointing my ndk_build Android.mk to the Android diistribution's external/jpeg directory, I expected consistency, however my build is still inconsistent.


You're pointing to a specific platform build, whose binary files may or may not corresponding to what is running on a real device.
Moreover, since libjpeg.so is not exposed by the NDK, there is no guarantee that it is available on a given Android device, or that its ABI matches your own platform builds.
 
The Android NDK Stable APIs does not directly address libjpeg. Nor does it address libpng, a static library that I have incorporated and used successfully.

True, and there is a reason for this.
 
Interestingly, the only other module in the Android distro to call the jpeg_create_decompress(&cinfo) function is ~/mydroid/system/extras/tests/bionic/libc/other/test_jpeg.c -- but this particular test_jpeg.c file is omitted from the Android.mk file in its parent directory.

I'm still investigating other examples in the distro code tree... but this remains a problem for me at the present time.


I think you don't understand what you're doing. Build your own version of the jpeg static library, and link it into your own shared lib.
 
-Kirk

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

Reply all
Reply to author
Forward
0 new messages