android-libjpeg-turbo icon indicating copy to clipboard operation
android-libjpeg-turbo copied to clipboard

error: undefined reference to 'jsimd_can_rgb_gray'

Open hoozh opened this issue 9 years ago • 6 comments

I'm not familiar with makefile, please help.

I meet errors when linking libjpeg-turbo to my own module.

.....
.....
[armeabi] Compile thumb  : jpeg-turbo <= jdatadst-tj.c
[armeabi] Compile thumb  : jpeg-turbo <= jdatasrc-tj.c
[armeabi] StaticLibrary  : libjpeg-turbo.a
[armeabi] SharedLibrary  : libimage_decode.so
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jccolor.c:603: error: undefined reference to 'jsimd_can_rgb_gray'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jccolor.c:658: error: undefined reference to 'jsimd_can_rgb_ycc'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jccolor.c:718: error: undefined reference to 'jsimd_rgb_gray_convert'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jccolor.c:718: error: undefined reference to 'jsimd_rgb_ycc_convert'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jcsample.c:502: error: undefined reference to 'jsimd_can_h2v1_downsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jcsample.c:520: error: undefined reference to 'jsimd_can_h2v2_downsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jcsample.c:537: error: undefined reference to 'jsimd_h2v1_downsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jcsample.c:537: error: undefined reference to 'jsimd_h2v2_downsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jdmerge.c:591: error: undefined reference to 'jsimd_can_h2v2_merged_upsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jdmerge.c:608: error: undefined reference to 'jsimd_can_h2v1_merged_upsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jdmerge.c:624: error: undefined reference to 'jsimd_h2v2_merged_upsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jdmerge.c:624: error: undefined reference to 'jsimd_h2v1_merged_upsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jdsample.c:458: error: undefined reference to 'jsimd_can_h2v1_fancy_upsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jdsample.c:463: error: undefined reference to 'jsimd_can_h2v1_upsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jdsample.c:472: error: undefined reference to 'jsimd_can_h2v2_fancy_upsample'
E:/Proj/RTMeasure/CameraEx/jni/vendor/libjpeg-turbo/libjpeg-turbo-1.4.1/jdsample.c:478: error: undefined reference to 'jsimd_can_h2v2_upsample'
.....
.....

here is my module's android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE            := image_decode
LOCAL_SRC_FILES         := imagedecode.c
LOCAL_STATIC_LIBRARIES  += libjpeg-turbo 
LOCAL_LDLIBS            := -llog
include $(BUILD_SHARED_LIBRARY)

hoozh avatar Oct 21 '15 00:10 hoozh

You need NDK 10e or later.

sorccu avatar Oct 21 '15 01:10 sorccu

Already upgrade to NDK 10e

I solved the problem, but i don't know if it is right

Modify file vendor/libjpeg-turbo/Android.mk

change line 87

else ifeq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_CFLAGS += \
    -DSIZEOF_SIZE_T=4 \

to

else ifeq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_SRC_FILES += \
    $(SOURCE_PATH)/simd/jsimd_arm.c \
    $(SOURCE_PATH)/simd/jsimd_arm_neon.S \

LOCAL_CFLAGS += \
    -DSIZEOF_SIZE_T=4 \

hoozh avatar Oct 21 '15 05:10 hoozh

Hmm, well, actually I think our README is a bit wrong... armeabi (older than v7) doesn't necessarily support NEON, so we might actually have to remove armeabi from the supported ABIs. Your patch works (well, it compiles), but it's not guaranteed to work on actual devices.

sorccu avatar Oct 21 '15 08:10 sorccu

In principle, there are ARM processors with NEON, and this can be sniffed at runtime. But this is probably not worth the effort. As of 12/26/2015, the official statistics page shows less than 3.5% of all Android devices running versions below Ice Cream Sandwich, which are potentially capable to run on ARM v6.

alexcohn avatar Dec 27 '15 08:12 alexcohn

Yes, libjpeg-turbo can actually do the runtime check. However since it's impossible for me to even try it out without having access to a plain armeabi device (preferably one without neon and one with neon, so two in total), and have never even seen one in person, I never bothered. If someone wants to sponsor a new device or donate their old used device for the cause, I could probably take a look.

sorccu avatar Dec 27 '15 17:12 sorccu

to solve the problem you need to add the jsimd_none.c in the armeabi section.

In Android.mk, change this:

else ifeq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_CFLAGS += \
    -DSIZEOF_SIZE_T=4 \

to this:

else ifeq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_SRC_FILES += $(SOURCE_PATH)/jsimd_none.c

LOCAL_CFLAGS += \
    -DSIZEOF_SIZE_T=4 \

perracodex avatar Jan 06 '16 21:01 perracodex