how to build opencv with clang and APP_STL := c++_static

asked 2016-03-25 04:47:44 -0600

whtank gravatar image

updated 2016-03-25 05:45:11 -0600

Our JNI codes are built with clang and APP_STL:=c++_static, however, after downloaded openCV and tried to link static openCV libraries to our app. Link error happens due to default openCV static libraries are built with gnustl_static.

So we tried to build openCV ourselves with c++_static, but failed to build with follow script. cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake .. -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang3.5 -DANDROID_STL=c++_static make -j8

who can help me?

build error placed here: Generating opencl_kernels_features2d.cpp, opencl_kernels_features2d.hpp Scanning dependencies of target hello-android Scanning dependencies of target opencv_objdetect Scanning dependencies of target opencv_features2d [ 48%] Building CXX object samples/android/CMakeFiles/hello-android.dir/hello-android/main.cpp.o [ 48%] [ 48%] Building CXX object modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/cascadedetect.cpp.o [ 48%] Building CXX object modules/ts/CMakeFiles/opencv_ts.dir/src/cuda_perf.cpp.o Building CXX object modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/cascadedetect_convert.cpp.o [ 48%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/agast.cpp.o [ 48%] Building CXX object modules/ts/CMakeFiles/opencv_ts.dir/src/cuda_test.cpp.o Linking CXX executable ../../bin/hello-android ../../lib/armeabi-v7a/libopencv_imgcodecs.a(loadsave.cpp.o):/CODES/OpenCV_Source/modules/imgcodecs/src/loadsave.cpp:function std::vector<unsigned char,="" std::allocator<unsigned="" char=""> >::_M_fill_insert(__gnu_cxx::__normal_iterator<unsigned char*,="" std::vector<unsigned="" char,="" std::allocator<unsigned="" char=""> > >, unsigned int, unsigned char const&): error: undefined reference to 'std::__throw_length_error(char const*)' ../../lib/armeabi-v7a/libopencv_imgcodecs.a(loadsave.cpp.o):/CODES/OpenCV_Source/modules/imgcodecs/src/loadsave.cpp:function _GLOBAL__sub_I_loadsave.cpp: error: undefined reference to 'std::ios_base::Init::Init()' ../../lib/armeabi-v7a/libopencv_imgcodecs.a(loadsave.cpp.o):/CODES/OpenCV_Source/modules/imgcodecs/src/loadsave.cpp:function _GLOBAL__sub_I_loadsave.cpp: error: undefined reference to 'std::ios_base::Init::~Init()' ../../lib/armeabi-v7a/libopencv_imgcodecs.a(grfmt_exr.cpp.o):/CODES/OpenCV_Source/modules/imgcodecs/src/grfmt_exr.cpp:function _GLOBAL__sub_I_grfmt_exr.cpp: error: undefined reference to 'std::ios_base::Init::Init()' ../../lib/armeabi-v7a/libopencv_imgcodecs.a(grfmt_exr.cpp.o):/CODES/OpenCV_Source/modules/imgcodecs/src/grfmt_exr.cpp:function _GLOBAL__sub_I_grfmt_exr.cpp: error: undefined reference to 'std::ios_base::Init::~Init()'

edit retag flag offensive close merge delete

Comments

Hi there, could you please tell if you have found a solution for your problem?

Gregory K gravatar imageGregory K ( 2017-01-25 05:44:55 -0600 )edit