title: OpenCV, Android and JNI
body: <p>I'm developing a Android application which JNI code and this code makes use of OpenCV library.</p>
  
  <p>The .c class of JNI code is "<strong>sintetica.c</strong>":</p>
  
  <pre><code>#include &lt;jni.h&gt;
  #include "sintetica.h"
  
  #include &lt;opencv/cv.h&gt;
  #include &lt;opencv2/highgui/highgui_c.h&gt;
  #include &lt;opencv2/imgproc/imgproc_c.h&gt;
  #include &lt;opencv2/imgproc/types_c.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;limits.h&gt;
  
  jint  Java_com_example_imagen3d_Imagen3DActivity_sintetica(JNIEnv *env, jobject thiz,jint argc, jchar *argv[]) {
  
  ...
  
      return 0;
  
  }
  </code></pre>
  
  <p>The <strong>Android.mk</strong> file :</p>
  
  <pre><code>LOCAL_PATH := $(call my-dir)
  include $(CLEAR_VARS)
  
  OPENCV_CAMERA_MODULES:=off
  OPENCV_INSTALL_MODULES:=on
  OPENCV_LIB_TYPE:=STATIC
  
  include /home/vmg/workspace/android/OpenCV-2.4.5-android-sdk/sdk/native/jni/OpenCV.mk
  
  LOCAL_MODULE :=sintetica
  LOCAL_LDLIBS += -llog -ldl
  LOCAL_SRC_FILES :=sintetica.c
  
  include $(BUILD_SHARED_LIBRARY)
  </code></pre>
  
  <p>The <strong>Application.mk</strong> file :</p>
  
  <pre><code>APP_STL := gnustl_static
  APP_CPPFLAGS := -frtti -fexceptions
  APP_ABI := armeabi-v7a armeabi x86
  APP_PLATFORM := android-8
  </code></pre>
  
  <p>And the <strong>Java class</strong>:</p>
  
  <pre><code>![public class Imagen3DActivity  extends Activity {
         ...
      public native int Java_com_example_imagen3d_Imagen3DActivity_sintetica(int argc, char argv\[\]);   
      static {
          System.loadLibrary("sintetica");
      }  
  }]
  </code></pre>
  
  <p>I'm a Linux user and I'm using Eclipse Juno and Opencv 2.4.5, although for the .c class i used OpenCV library of linux repositories and i don't know what version is it.</p>
  
  <p>A part of the errors which happen is as follows:</p>
  
  <pre><code>20:10:55 **** Incremental Build of configuration Default for project Imagen3D ****
  /home/vmg/android/android-ndk-r8c/ndk-build 
  SharedLibrary  : libsintetica.so
  /home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x86): error: undefined reference to 'std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, std::allocator&lt;char&gt; const&amp;)'
  /home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x94): error: undefined reference to 'std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, std::allocator&lt;char&gt; const&amp;)'
  /home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0xa4): error: undefined reference to 'std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, std::allocator&lt;char&gt; const&amp;)'
  /home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x11c): error: undefined reference to 'std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, std::allocator&lt;char&gt; const&amp;)'
  /home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x9c4): error: undefined reference to 'std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::_Rep::_M_destroy(std::allocator&lt;char&gt; const&amp;)'
  /home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0xb78): error: undefined reference to 'std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::_Rep::_S_empty_rep_storage'
  /home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x2058): error: undefined reference to '__cxa_end_cleanup'
  /home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x2146): error: undefined reference to 'std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::_Rep::_M_destroy(std::allocator&lt;char&gt; const&amp;)'
  ...
  </code></pre>
  
  <p>Thanks!</p>