New linker error when moving to OpenCV 2.4.2 for Android (NDK, static linking)

1,103 views
Skip to first unread message

Philip Lamb

unread,
Jul 15, 2012, 10:49:52 PM7/15/12
to android...@googlegroups.com
Hi all,

We've previously been successfullty using OpenCV 2.4.0 for Android in our native C++ project. We build with Android NDK r8, targeting API level 7 and later. Build host is Mac OS X 10.7.4.

Now I've just updated to OpenCV 2.4.2, and the link phase is failing, with missing symbols "mbstowcs" and "wcstombs".

android/obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `cv::toUtf16(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
persistence.cpp:(.text._ZN2cv7toUtf16ERKSs+0x52): undefined reference to `mbstowcs'
android/obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `cv::fromUtf16(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
persistence.cpp:(.text._ZN2cv9fromUtf16ERKSbIwSt11char_traitsIwESaIwEE+0x56): undefined reference to `wcstombs'

Our Application.mk includes:
APP_OPTIM := release
APP_ABI := armeabi armeabi-v7a x86
APP_PLATFORM    := android-7
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions

and our Android.mk includes:
OPENCV_PACKAGE_DIR:=$(MY_LOCAL_DIR)/jni/OpenCV-2.4.2
OPENCV_LIB_TYPE:=STATIC
OPENCV_CAMERA_MODULES:=off
include $(OPENCV_PACKAGE_DIR)/jni/OpenCV.mk
LOCAL_ARM_MODE := arm
LOCAL_LDLIBS += -llog -lGLESv1_CM
LOCAL_STATIC_LIBRARIES += opencv_flann opencv_core tbb

Any ideas?

Philip Lamb

unread,
Jul 15, 2012, 11:01:56 PM7/15/12
to android...@googlegroups.com
OK, another topic on a similar question elsewhere suggested that mbstowcs and wcstombs weren't available in the Android libc prior to API level 8 (i.e. Android OS 2.2). So I tested with a modification to our Application.mk:

APP_PLATFORM    := android-8

and the link issue disappears.

So... I guess, it needs to be noted somewhere that OpenCV 2.4.2 requires API level 8, i.e. Android OS 2.2. Either that, or there need to be some changes to check at runtime if the wide char functions are available in libc, and if not, then disable the bits of OpenCV that use them.
Reply all
Reply to author
Forward
0 new messages