opencv: Error from STL library while compiling for Android with ANDROID_STL=c++_static(shared)
- OpenCV => 3.2
- Operating System / Platform => OSX
I have failed to compile opencv with NDK after setting ANDROID_STL to c++_static or c++_shared. I have tried NDK r11 through r14, after fixing the NDK folder structuring problem, I still get errors while compiling any files that include STL headers such as <iostream>. Error messages are like the following:
In file included from /path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/cwchar:107:0,
from /path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/string:438,
from /path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__locale:15,
from /path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/ios:216,
from /path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/iostream:38,
from /opencv/3rdparty/libtiff/tiffio.hxx:34,
from /opencv/3rdparty/libtiff/tif_stream.cxx:31:
/path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/cwctype:88:9: error: '::iswblank' has not been declared
using ::iswblank;
^
In file included from /path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/string:438:0,
from /path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__locale:15,
from /path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/ios:216,
from /path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/iostream:38,
from /opencv/3rdparty/libtiff/tiffio.hxx:34,
from /opencv/3rdparty/libtiff/tif_stream.cxx:31:
/path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/cwchar:132:9: error: '::vfwscanf' has not been declared
using ::vfwscanf;
^
/path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/cwchar:133:9: error: '::vswscanf' has not been declared
using ::vswscanf;
^
/path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/cwchar:134:9: error: '::vwscanf' has not been declared
using ::vwscanf;
^
/path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/cwchar:150:9: error: '::wcstof' has not been declared
using ::wcstof;
^
/path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/cwchar:151:9: error: '::wcstold' has not been declared
using ::wcstold;
^
/path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/cwchar:155:9: error: '::wcstoll' has not been declared
using ::wcstoll;
^
/path/to/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/cwchar:159:9: error: '::wcstoull' has not been declared
using ::wcstoull;
and there’re hundreds more of them. Have tried replacing the toolchain from NDK/build/cmake as well as standalone toolchain exported from NDK/build/tools/make-standalone-toolchain.sh, all efforts failed and resulted in the same error as above.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (5 by maintainers)
Android NDK provides own CMake toolchain file since r15. So solution is very simple - use it instead of custom OpenCV version (which leave for legacy NDKs).
Try something like this:
This works! Thank you very much!
Hi all,
I’m hitting the same issue, trying to compile OpenCV 3.4.1 or HEAD with c++_static and NDKr16.
I need C++11, so gnustl is not an option, and it appears to be impossible to set clang as the compiler.
This makes OpenCV not usable together with C++11 on Android, not to mention that gcc support is going to be discontinued in NDKr17 (coming very soon) and will be removed in NDKr18: https://github.com/android-ndk/ndk/wiki/Changelog-r17-beta2.
I could contribute some code, but I need some advice on where to start: the cmake files in OpenCV take thousands of lines of mostly undocumented code.
@feliwir ,
BTW, Android NDK r15 has own CMake toolchain for Android - you could try to use it.