Problem with 3rd Party Lib When Building Static Library For ARM64 With Visual Studio (2019)

Hello guys,
I’ve written a small library that uses some of the OpenCV functionality.
I was also able to link the OpenCV stuff into my library and compile it for Android (Clang 5.0, Android NDK R21e). The prototype app works smoothly within an emulator.
For performance reasons I compiled the .so file for x86 architecture.

Now I wanted to compile it for ARM64 but I got the following error:
aarch64-linux-android/4.9.x/…/…/…/…/aarch64-linux-android/bin\ld: cannot find -lippiw
aarch64-linux-android/4.9.x/…/…/…/…/aarch64-linux-android/bin\ld: cannot find -lippicv

As I understand it, this is because these libs don’t exist for ARM64. That’s why they are missing in the folder ‘native\3rdparty\libs\arm64-v8a’ of the OpenCV SDK.

I’ve found severeal user contributions saying to compile OpenCV without ‘IPP’. Seems reasonable, but I thought:
I’m using the OpenCV 4.5.4 Android SDK. The folder ‘sdk\native\staticlibs\arm64-v8a’ and ‘sdk\native\3rdparty\libs\arm64-v8a’ should have all the libs I need, like when I use the libs for x86.
So, I deleted the libs from the Library Dependencies in Visual Studio. Now I’m getting way more errors. The first one looks like this:

…native\staticlibs\arm64-v8a\libopencv_imgproc.a(color_lab.cpp.o): In function cv::RGB2Lab_f::operator()(float const*, float*, int) const’:
1>color_lab.cpp:(.text._ZNK2cv9RGB2Lab_fclEPKfPfi[_ZNK2cv9RGB2Lab_fclEPKfPfi]+0x390): undefined reference to ‘lrintf’

How can I solve this? Any ideas?

Greetz
Jan

I’ve found the solution.
First, I had to add some options to the linker Command Line: -lm -lz
Then I had to change the order of the libraries in the linker input dependencies:
opencv_imgcodecs;opencv_imgproc;opencv_calib3d;opencv_flann;opencv_features2d;opencv_core;tegra_hal;libjpeg-turbo;libopenjp2;IlmImf;libpng;libtiff;libwebp;ittnotify;tbb;opencv_highgui;opencv_videoio

This worked for me, and hopefully for others, too. :wink: