1

I am struggling already a few hours with the problem of calling cv::imdecode() in my native code for Android using the prebuild libraries of the OpenCV 2.3.1.

Here is what I am trying to do. I have library that detects for now QR code in the image BarcodesLibrary which is built as a static library. And then I have written some wrappers for JNI which ensures the conversion between Java/C++ objects - these modules are packaged into shared library JNI_QRBarcodesLibrary and the BarcodesLibrary is also linked into it.

And now become the errors showed in this dump. Errors relate to the inserting highgui module and calling imdecode(). Just have to mention yet that everything compiles fine and libraries are sucessfully imported to the android without imdecode().

"Compile++ thumb : JNI_QRBarcodesLibrary <= JNI_QRBarcodesLibrary.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= jDetectedMark.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= jImage.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= JNIWrapper.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= jPoint.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= jSize.cpp
"Compile++ thumb : BarcodesLibrary <= Image.cpp
"Compile++ thumb : BarcodesLibrary <= Barcode.cpp
"Compile++ thumb : BarcodesLibrary <= QrBarcode.cpp
Prebuilt       : libopencv_contrib.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_calib3d.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_objdetect.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_features2d.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_video.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_imgproc.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_highgui.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_ml.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_legacy.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_flann.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_core.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_libjpeg.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_libpng.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_libtiff.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_libjasper.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_zlib.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libgnustl_static.a <= <NDK>/sources/cxx-stl/gnu-libstdc++/libs/armeabi
StaticLibrary  : libBarcodesLibrary.a
SharedLibrary  : libJNI_QRBarcodesLibrary.so

And the build ends with this error:

./obj/local/armeabi/libopencv_highgui.a(grfmt_pxm.o):(.data.rel.ro+0x0): undefined reference to `vtable for __cxxabiv1::__enum_type_info'
./obj/local/armeabi/libopencv_highgui.a(bitstrm.o):(.data.rel.ro+0x0): undefined reference to `vtable for __cxxabiv1::__enum_type_info'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libJNI_QRBarcodesLibrary.so] Error 1

Well I was expecting that not all features inside this library will be supported while this library provides the OS dependent imshow, waitKey etc. But that it will be problem with the imdecode is what I was not counted with.

So do you have any ideas how to solve this problem or any other libraries that can be ported to Android and provide image decoding - especially JPEG format?

I am grateful for any tips. Thanks.

ITman
  • 141
  • 2
  • 12

1 Answers1

1

Use OpenCV.mk from OpenCV distribution for adding OpenCV into your project. It will resolve all the dependencies.

If you are using OpenCV prebuilt binaries from SourceForge, then you can find this file in share/OpenCV subfolder. You need to include OpenCV.mk directly from that folder.

Andrey Kamaev
  • 29,582
  • 6
  • 94
  • 88
  • I am already using it, just did a few changes inside this file. I hope that I have linked all libraries. But I will try it to use this makefile unchaged whether it helps. – ITman Mar 16 '12 at 11:59
  • Still the same error here. I am wonder why is this error thrown during building the shared library libJNI_QRBarcodesLibrary, but not libBarcodesLibrary. Because I already use imdecode and eventually imread in there... – ITman Mar 16 '12 at 12:15
  • imread isn't there. You have to pass OpenCV libraries to the libJNI_QRBarcodesLibrary link libraries too. – Andrey Kamaev Mar 16 '12 at 12:22
  • Yes, I figured it out, thanks anyway. Even size of the static library libBarcodesLibrary told me that something is wrong. But why is that? I though that while I build a library static that all dependencies should be resolved and necessary modules included into the library. Maybe I am still confused in static/shared build. – ITman Mar 16 '12 at 13:42
  • This make things obvious ;) http://stackoverflow.com/questions/2157629/linking-static-libraries-to-other-static-libraries – ITman Mar 16 '12 at 15:18