<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4.1.1</li>
<li>Operating System / Platform =&gt; Raspberry Pi, Raspbian</li>
<li>Compiler =&gt; CMake?</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">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: <a href="https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/" rel="nofollow">https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/</a> or <a href="https://www.deciphertechnic.com/install-opencv-python-on-raspberry-pi/" rel="nofollow">https://www.deciphertechnic.com/install-opencv-python-on-raspberry-pi/</a> but no matter what I do, I get this error:</p>
<p dir="auto"><code class="notranslate">/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</code></p>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">(Error while compiling the module)</p>
<h5 dir="auto">System information (version)</h5>
<p dir="auto">OpenCV =&gt; 4.1.1<br>
OS =&gt; Raspbian Buster (Debian 10)</p>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">When compiling OpenCV 4.1.1 on Raspbian, i get various undefined references to __atomic_xxx calls.  See <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="474648565" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/15192" data-hovercard-type="issue" data-hovercard-url="/opencv/opencv/issues/15192/hovercard" href="https://github.com/opencv/opencv/issues/15192">#15192</a>.  Adding <code class="notranslate">-DOPENCV_EXTRA_EXE_LINKER_FLAGS=-latomic</code> to cmake allows OpenCV to compile and install, but the generated libraries are missing the atomic library reference:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[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 =&gt; /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0xb6c77000)
	libdl.so.2 =&gt; /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6c41000)
	libpthread.so.0 =&gt; /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6c17000)
	librt.so.1 =&gt; /lib/arm-linux-gnueabihf/librt.so.1 (0xb6c00000)
	libtbb.so.2 =&gt; /srv/maverick/software/tbb/lib/libtbb.so.2 (0xb6bca000)
	libz.so.1 =&gt; /lib/arm-linux-gnueabihf/libz.so.1 (0xb6b9f000)
	libopenblas.so.0 =&gt; /srv/maverick/software/openblas/lib/libopenblas.so.0 (0xb6269000)
	libstdc++.so.6 =&gt; /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6122000)
	libm.so.6 =&gt; /lib/arm-linux-gnueabihf/libm.so.6 (0xb60a0000)
	libgcc_s.so.1 =&gt; /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6073000)
	libc.so.6 =&gt; /lib/arm-linux-gnueabihf/libc.so.6 (0xb5f25000)
	/lib/ld-linux-armhf.so.3 (0xb6fac000)
	libgfortran.so.5 =&gt; /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)"><pre class="notranslate"><code class="notranslate">[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 =&gt; /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0xb6c77000)
	libdl.so.2 =&gt; /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6c41000)
	libpthread.so.0 =&gt; /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6c17000)
	librt.so.1 =&gt; /lib/arm-linux-gnueabihf/librt.so.1 (0xb6c00000)
	libtbb.so.2 =&gt; /srv/maverick/software/tbb/lib/libtbb.so.2 (0xb6bca000)
	libz.so.1 =&gt; /lib/arm-linux-gnueabihf/libz.so.1 (0xb6b9f000)
	libopenblas.so.0 =&gt; /srv/maverick/software/openblas/lib/libopenblas.so.0 (0xb6269000)
	libstdc++.so.6 =&gt; /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6122000)
	libm.so.6 =&gt; /lib/arm-linux-gnueabihf/libm.so.6 (0xb60a0000)
	libgcc_s.so.1 =&gt; /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6073000)
	libc.so.6 =&gt; /lib/arm-linux-gnueabihf/libc.so.6 (0xb5f25000)
	/lib/ld-linux-armhf.so.3 (0xb6fac000)
	libgfortran.so.5 =&gt; /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)
</code></pre></div>
<p dir="auto">This means anything compiled against opencv also then has these same undefined errors.</p>
<p dir="auto">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.</p>