Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to build OpenCV for Android using Visual Studio?

Hello,

Short story:

Can anyone describe the process of how to use OpenCV in a C++ Project for Android in Visual Studio?


Long story:

I'm currently trying to build an OpenCV native plugin for Unity using Visual Studio. As it should be as platform independent as possible (except Linux), it's necessary to build the DLL for Windows, Android etc. That's also the reason why I'd prefer to stick to Visual Studio instead of Android Studio as it's (theoretically) possible to develop for all of those platforms there.

I already managed to setup OpenCV for UWP and Windows, however, I don't really know how to do this for Android. I already created a Visual Studio Cross-Platform C++ Project that Outputs a dynamic library (.so). It's compiling as long as I don't do anything OpenCV related in there.

My first try was to just use the normal OpenCV library for C++, but it gives me errors like "cannot use throw with exceptions disabled" and a lot more.

As a next step, I downloaded the OpenCV4Android .zip from the releases page and unzipped it. I added "OpenCV-android-sdk\sdk\native\jni\include" as additional include directory and "\OpenCV-android-sdk\sdk\native\libs\PLATFORM" as additional library directory, where "PLATFORM" is the build configuration (x64, x86, amd, etc.).

I then added "libopencv_core.a" to additional dependencies and tried to compile the whole thing, however, it says "There is no such file or directory: libopencv_core.a". If I remove it from the additional dependencies, it says "Linker command failed with exit code -1".

Also, I get a lot of errors saying "builtin function is not available because vector types are not supported".

How to build OpenCV for Android using Visual Studio?

Hello,

Short story:

Can anyone describe the process of how to use OpenCV in a C++ Project for Android in Visual Studio?


Long story:

I'm currently trying to build an OpenCV native plugin for Unity using Visual Studio. As it should be as platform independent as possible (except Linux), it's necessary to build the DLL for Windows, Android etc. That's also the reason why I'd prefer to stick to Visual Studio instead of Android Studio as it's (theoretically) possible to develop for all of those platforms there.

I already managed to setup OpenCV for UWP and Windows, however, I don't really know how to do this for Android. I already created a Visual Studio Cross-Platform C++ Project that Outputs a dynamic library (.so). It's compiling as long as I don't do anything OpenCV related in there.

My first try was to just use the normal OpenCV library for C++, but it gives me errors like "cannot use throw with exceptions disabled" and a lot more.

As a next step, I downloaded the OpenCV4Android .zip from the releases page and unzipped it. I added "OpenCV-android-sdk\sdk\native\jni\include" as additional include directory and "\OpenCV-android-sdk\sdk\native\libs\PLATFORM" as additional library directory, where "PLATFORM" is the build configuration (x64, x86, amd, etc.).

I then added "libopencv_core.a" to additional dependencies and tried to compile the whole thing, however, it says "There is no such file or directory: libopencv_core.a". If I remove it from the additional dependencies, it says "Linker command failed with exit code -1".

Also, I get a lot of errors saying "builtin function is not available because vector types are not supported".

How to build OpenCV for Android using Visual Studio?

Hello,

Short story:

Can anyone describe the process of how to use OpenCV in a C++ Project for Android in Visual Studio?


Long story:

I'm currently trying to build an OpenCV native plugin for Unity using Visual Studio. As it should be as platform independent as possible (except Linux), it's necessary to build the DLL for Windows, Android etc. That's also the reason why I'd prefer to stick to Visual Studio instead of Android Studio as it's (theoretically) possible to develop for all of those platforms there.

I already managed to setup OpenCV for UWP and Windows, however, I don't really know how to do this for Android. I already created a Visual Studio Cross-Platform C++ Project that Outputs a dynamic library (.so). It's compiling as long as I don't do anything OpenCV related in there.

My first try was to just use the normal OpenCV library for C++, but it gives me errors like "cannot use throw with exceptions disabled" and a lot more.

As a next step, I downloaded the OpenCV4Android .zip from the releases page and unzipped it. I added "OpenCV-android-sdk\sdk\native\jni\include" as additional include directory and "\OpenCV-android-sdk\sdk\native\libs\PLATFORM" as additional library directory, where "PLATFORM" is the build configuration (x64, x86, amd, etc.).

I then added "libopencv_core.a" to additional dependencies and tried to compile the whole thing, however, it says "There is no such file or directory: libopencv_core.a". If I remove it from the additional dependencies, it says "Linker command failed with exit code -1".

Also, I get a lot of errors saying "builtin function is not available because vector types are not supported".