Undefined reference IPP when building against OpenCV 4.5.2

I am building OpenCV 4.5.2 with the cudadnn support on Ubuntu 20.04. The OpenCV build is successful. However when building a catkin workspace with an executable that references this version of OpenCV the following error occurs:

.../path/to/my_file.so: undefined reference to `ippicviNorm_L1_32f_C3CMR'
.../path/to/my_file.so: undefined reference to `__itt_task_begin_ptr__3_0'
.../path/to/my_file.so: undefined reference to `ippicviAnd_8u_C1R'
.../path/to/my_file.so: undefined reference to `ippicviNorm_Inf_32f_C1MR'
.../path/to/my_file.so: undefined reference to `ippicviNormRel_L2_16u_C1R'
.../path/to/my_file.so: undefined reference to `ippicviNorm_L2_16u_C3CMR'
.../path/to/my_file.so: undefined reference to `ippicviNorm_Inf_32f_C3CMR'
.../path/to/my_file.so: undefined reference to `__itt_metadata_add_ptr__3_0'
.../path/to/my_file.so: undefined reference to `ippicviCompare_8u_C1R'
.../path/to/my_file.so: undefined reference to `ippicviNormRel_L2_16s_C1R'
.../path/to/my_file.so: undefined reference to `ippicvsMinEvery_16u'
.../path/to/my_file.so: undefined reference to `llwiCopyChannel'
.../path/to/my_file.so: undefined reference to `ippicviNormDiff_Inf_16u_C3CMR'
.../path/to/my_file.so: undefined reference to `ippicviNormRel_L2_32f_C1MR'
.../path/to/my_file.so: undefined reference to `ippicviMul_16u_C1RSfs'

I am running a AMD processor and built with IPP and ITT support off (tried with on as well). Here are my cmake arguments:

cmake -D CMAKE_INSTALL_PREFIX=/home/user/libs/opencv-4.5.2/release/installed \
      -D CMAKE_BUILD_TYPE=RELEASE \
      -D WITH_TBB=ON \
      -D ENABLE_FAST_MATH=1 \
      -D CUDA_FAST_MATH=1 \
      -D WITH_CUBLAS=1 \
      -D WITH_CUDA=ON \
      -D BUILD_opencv_cudacodec=OFF \
      -D WITH_CUDNN=ON \
      -D OPENCV_DNN_CUDA=ON \
      -D CUDA_ARCH_BIN=7.5 \
      -D WITH_V4L=ON \
      -D WITH_QT=OFF \
      -D WITH_OPENGL=ON \
      -D WITH_GSTREAMER=ON \
      -D OPENCV_GENERATE_PKGCONFIG=ON \
      -D OPENCV_PC_FILE_NAME=opencv.pc \
      -D OPENCV_ENABLE_NONFREE=ON \
      -D OPENCV_PYTHON3_INSTALL_PATH=~/.virtualenvs/cv/lib/python3.8/site-packages \
      -D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
      -D OPENCV_EXTRA_MODULES_PATH=/home/user/projects/opencv_contrib-4.5.2/modules \
      -D INSTALL_PYTHON_EXAMPLES=OFF \
      -D INSTALL_C_EXAMPLES=OFF \
      -D BUILD_EXAMPLES=OFF \
      -D CUDNN_INCLUDE_DIR=/usr/local/cuda-11.1/targets/x86_64-linux/include/ \
      -D CUDNN_LIBRARY=/usr/lib/x86_64-linux-gnu/libcudnn.so \
      -D CUDNN_VERSION=8.4.1 \
      -D WITH_ITT=OFF \
      -D WITH_IPP=OFF \
      ..

Why is it attempting to link against IPP still? Is there a patch fix somewhere to prevent this from happening?

what did you hide there?

/usr/bin/ld: /home/user/projects/my_project/devel/.private/my_project/lib/libmy_file.so: undefined reference to ippicviNorm_L1_32f_C3CMR is the rest of the path. It points to a .so file it fails to build

so you’re not building OpenCV now, but your own program… and your own program is asking for these IPP identifiers? that’s odd

Yes my own program references OpenCV which is causing the linking issue.

For example, this line of the arithm_ipp.hpp in the OpenCV repository contains a instance of the undefined reference in my program (undefined reference to 'ippicviMul_16u_C1RSfs') .

However this should never be linked because #if ARITHM_USE_IPP should be set to false b/c #HAVE_IPP macro should be false.

@crackwitz This question is likely better suited for a ROS forum. It appears that the ROS package is attempting to link two separate OpenCV versions despite having set

find_package(OpenCV 4.6.0 REQUIRED COMPONENTS core)

in the CMakeLists.txt. I believe the other version (4.2.0) is causing the problem.

please avoid that, for the hell it will invoke.