I am trying to link opencv to my c++ project (shared library) in Visual Studio. I have tried using both precompiled headers for WIndows as well as tried compiling myself from the source. But I get the same error.
I have compiled OpenCV binaries with GCC using this tutorial (OpenCV C++ installation on Windows with MinGW | by RAJAT KANTI Bhattacharjee | csmadeeasy | Medium) and linked the directories and files under the project settings such as C/C++ > Additional Include Directories as well as under Linker > Input > Additional Directories with no luck. My code is able to recognize OpenCV variables however, I believe I am not just linking libraries right.
The error output I get is:
1>Target Link:
1> C:\Microsoft\AndroidNDK64\android-ndk-r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/…/…/…/…/arm-linux-androideabi/bin\ld: error: C:\Program_Files\Release\install\x64\mingw\bin\libopencv_features2d3414.dll:1:3: invalid character
1> C:\Microsoft\AndroidNDK64\android-ndk-r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/…/…/…/…/arm-linux-androideabi/bin\ld: error: C:\Program_Files\Release\install\x64\mingw\bin\libopencv_features2d3414.dll:1:3: syntax error, unexpected $end
1> C:\Microsoft\AndroidNDK64\android-ndk-r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/…/…/…/…/arm-linux-androideabi/bin\ld: error: C:\Program_Files\Release\install\x64\mingw\bin\libopencv_features2d3414.dll: not an object or archive
1> undefined reference to ‘cv::Mat::Mat(int, int, int)’
1> undefined reference to ‘cv::Mat::~Mat()’
1> undefined reference to ‘cv::ORB::create(int, float, int, int, int, int, int, int, int)’
1> undefined reference to ‘cv::Mat::Mat()’
1> undefined reference to ‘cv::Mat::Mat()’
1> undefined reference to ‘cv::Mat::~Mat()’
1> undefined reference to ‘cv::Mat::~Mat()’
1> clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Application Type\Android\3.0\Android.Common.targets(119,5): error MSB6006: “clang.exe” exited with code 1.
1>Done building target “Link” in project “TestSharedLibrary.vcxproj” – FAILED.
I am using Debug configuration and have tried with various Platforms (x64, ARM, ARM64) where I get the same error but for Platform x86 the error i get is:
1>Target Link:
1> undefined reference to ‘cv::ORB::create(int, float, int, int, int, int, int, int, int)’
1> undefined reference to ‘cv::fastFree(void*)’
1> undefined reference to ‘cv::Mat::create(int, int const*, int)’
1> undefined reference to ‘cv::Mat::deallocate()’
1> clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Application Type\Android\3.0\Android.Common.targets(119,5): error MSB6006: “clang.exe” exited with code 1.
1>Done building target “Link” in project “TestSharedLibrary.vcxproj” – FAILED.
How can I resolve this linking issue?