Issue 1:
System information (version)

OpenCV => 4.1.1

Operating System / Platform => Raspberry Pi, Raspbian

Compiler => CMake?

Detailed description

I am working on Raspberry Pi 4 which has python 3.7 installed. As Pi wheels has not added opencv to their list in python3.7, I am forced to build from source. I have followed a couple of tutorials like: https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/ or https://www.deciphertechnic.com/install-opencv-python-on-raspberry-pi/ but no matter what I do, I get this error:

/usr/bin/ld: ../../lib/libopencv_core.so.4.1.1: undefined reference to '__atomic_fetch_add_8' /usr/bin/ld: ../../lib/libopencv_core.so.4.1.1: undefined reference to '__atomic_fetch_sub_8' /usr/bin/ld: ../../lib/libopencv_core.so.4.1.1: undefined reference to '__atomic_store_8' /usr/bin/ld: ../../lib/libopencv_core.so.4.1.1: undefined reference to '__atomic_load_8' /usr/bin/ld: ../../lib/libopencv_core.so.4.1.1: undefined reference to '__atomic_compare_exchange_8' collect2: error: ld returned 1 exit status make[2]: *** [modules/core/CMakeFiles/opencv_test_core.dir/build.make:571 : bin/opencv_test_core] Error 1 make[1]: *** [CMakeFiles/Makefile2:2678: modules/core/CMakeFiles/opencv_test_core.dir/all] Error 2 make: *** [Makefile:163: all] Error 2

Steps to reproduce

(Error while compiling the module)

Issue 2:
System information (version)

OpenCV => 4.1.1

OS => Raspbian Buster (Debian 10)

Detailed description

When compiling OpenCV 4.1.1 on Raspbian, i get various undefined references to __atomic_xxx calls. See #15192. Adding -DOPENCV_EXTRA_EXE_LINKER_FLAGS=-latomic to cmake allows OpenCV to compile and install, but the generated libraries are missing the atomic library reference:

[dev] [mav@maverick-raspberry ~]$ ldd -r /srv/maverick/software/opencv/lib/libopencv_core.so.4.1.1
linux-vdso.so.1 (0xbec57000)
/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0xb6c77000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6c41000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6c17000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xb6c00000)
libtbb.so.2 => /srv/maverick/software/tbb/lib/libtbb.so.2 (0xb6bca000)
libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0xb6b9f000)
libopenblas.so.0 => /srv/maverick/software/openblas/lib/libopenblas.so.0 (0xb6269000)
libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6122000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb60a0000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6073000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb5f25000)
/lib/ld-linux-armhf.so.3 (0xb6fac000)
libgfortran.so.5 => /usr/lib/arm-linux-gnueabihf/libgfortran.so.5 (0xb5e4c000)
undefined symbol: __atomic_compare_exchange_8	(/srv/maverick/software/opencv/lib/libopencv_core.so.4.1.1)
undefined symbol: __atomic_fetch_sub_8	(/srv/maverick/software/opencv/lib/libopencv_core.so.4.1.1)
undefined symbol: __atomic_load_8	(/srv/maverick/software/opencv/lib/libopencv_core.so.4.1.1)
undefined symbol: __atomic_store_8	(/srv/maverick/software/opencv/lib/libopencv_core.so.4.1.1)
undefined symbol: __atomic_fetch_add_8	(/srv/maverick/software/opencv/lib/libopencv_core.so.4.1.1)

This means anything compiled against opencv also then has these same undefined errors.

I would expect cmake to detect if atomic library is needed and add it automatically, and it should be linked into the core library, and others where necessary.