# Linker errors in Android App using OpenCV: undefined reference to 'std::\_\_ndk1::to\_string(int)

**URL:** <https://forum.opencv.org/t/linker-errors-in-android-app-using-opencv-undefined-reference-to-std-to-string-int/2503>\
**Category:** Android/Java\
**Tags:** android, ndk\
**Created:** [March 31, 2021, 8:53am UTC](https://forum.opencv.org/t/linker-errors-in-android-app-using-opencv-undefined-reference-to-std-to-string-int/2503 "2021-03-31T08:53:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kazanian](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@Kazanian](https://forum.opencv.org/u/Kazanian)\
**Post date:** [March 31, 2021, 8:53am UTC](https://forum.opencv.org/t/linker-errors-in-android-app-using-opencv-undefined-reference-to-std-to-string-int/2503/1 "2021-03-31T08:53:46Z")

</div>

Hi,

I need to build OpenCV and integrate it into my Capacitor Android Plugin. Building OpenCV and including OpenCV in my c++ code worked. But when I ran the app, there are a lot of errors of this kind:

> logtagconfigparser.cpp:301: error: undefined reference to ‘std::\_\_ndk1::to\_string(int)’

When I google this error, the proposed solution is to set APP\_STL:=c++\_static. So, I put this in my Android.mk and Apllication.mk but nothing changed.  
Can you help me on this? I’m really stuck here.

Some more infos:

I compiled OpenCV using this parameters:

> cmake “…” -DCMAKE\_TOOLCHAIN\_FILE=“/home/administrator/Android/Sdk/ndk/22.0.7026061/build/cmake/android.toolchain.cmake” -DANDROID\_NDK=“/home/administrator/Android/Sdk/ndk/22.0.7026061” -DANDROID\_SDK\_ROOT=“/home/administrator/Android/Sdk” -DANDROID\_NATIVE\_API\_LEVEL=28 -DBUILD\_ANDROID\_PROJECTS=OFF -DBUILD\_ANDROID\_EXAMPLES=OFF -DBUILD\_PERF\_TESTS=OFF -DBUILD\_TESTS=OFF -DBUILD\_SHARED\_LIBS=OFF -DBUILD\_opencv\_world=OFF -DANDROID\_STL=c++\_static

To use OpenCV in the Capacitor-Android-Plugin, I set this in the Android.mk

> OPENCV\_INSTALL\_MODULES:=on  
> OPENCV\_LIB\_TYPE:=STATIC  
> APP\_STL:=c++\_static  
> APP\_CPPFLAGS := -frtti -fexceptions -std=c++11  
> ANDROID\_STL:=c++\_static  
> include …/opencv/build/install/sdk/native/jni/OpenCV.mk

And also set the include path in Android.mk to something like this:

…/opencv/build/install/sdk/native/jni/include/

Thanks in advance for any help!
