Repository: conan-io/conan-center-index

Issue:
[package] opencv/4.5.2: armv8 does not link libtregra_hal.a during project linkage --> results in missing symbols
### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **opencv/4.5.2**
  * Operating System+version: **Linux Ubuntu 21.04**
  * Compiler+version: **GCC 11 aarch64**
  * Compiler+version: **clang 12**
  * Conan version: **conan 1.35.2**
  * Python version: **Python 3.9.4**


### Steps to reproduce (Include if Applicable)

- cross-compile opencv from x86_64 to armv8 with clang using libstdc++11
- use opencv package in project and link statically

can be fixed via linkage against libtegra_hal.a

It seems that this transient dependency is missing as linker export for armv8 cross-compile builds.

### Logs (Include/Attach if Applicable)
<details><summary>missing symbols from tegra_hal</summary>

```
[...]
ld.lld: error: undefined symbol: carotene_o4t::isSupportedConfiguration()
>>> referenced by color_hsv.dispatch.cpp
>>>               color_hsv.dispatch.cpp.o:(cv::hal::cvtBGRtoHSV(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool)) in archive /home/build-user/.conan/data/opencv/4.5.2/_/_/package/be4c8261869726f21e2b0dcec6af3918a41bbacd/lib/libopencv_imgproc.a
>>> referenced by color_rgb.dispatch.cpp
>>>               color_rgb.dispatch.cpp.o:(cv::hal::cvtBGRtoBGR(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, int, bool)) in archive /home/build-user/.conan/data/opencv/4.5.2/_/_/package/be4c8261869726f21e2b0dcec6af3918a41bbacd/lib/libopencv_imgproc.a
>>> referenced by color_rgb.dispatch.cpp
>>>               color_rgb.dispatch.cpp.o:(cv::hal::cvtBGRtoBGR5x5(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, bool, int)) in archive /home/build-user/.conan/data/opencv/4.5.2/_/_/package/be4c8261869726f21e2b0dcec6af3918a41bbacd/lib/libopencv_imgproc.a
>>> referenced 79 more times

ld.lld: error: undefined symbol: carotene_o4t::rgb2hsv(carotene_o4t::Size2D const&, unsigned char const*, long, unsigned char*, long, int)
>>> referenced by color_hsv.dispatch.cpp
>>>               color_hsv.dispatch.cpp.o:(TegraCvtColor_rgb2hsvf_Invoker::operator()(cv::Range const&) const) in archive /home/build-user/.conan/data/opencv/4.5.2/_/_/package/be4c8261869726f21e2b0dcec6af3918a41bbacd/lib/libopencv_imgproc.a
>>> referenced by color_hsv.dispatch.cpp
>>>               color_hsv.dispatch.cpp.o:(TegraCvtColor_rgb2hsv_Invoker::operator()(cv::Range const&) const) in archive /home/build-user/.conan/data/opencv/4.5.2/_/_/package/be4c8261869726f21e2b0dcec6af3918a41bbacd/lib/libopencv_imgproc.a

ld.lld: error: undefined symbol: carotene_o4t::bgr2hsv(carotene_o4t::Size2D const&, unsigned char const*, long, unsigned char*, long, int)
>>> referenced by color_hsv.dispatch.cpp
>>>               color_hsv.dispatch.cpp.o:(TegraCvtColor_bgr2hsvf_Invoker::operator()(cv::Range const&) const) in archive /home/build-user/.conan/data/opencv/4.5.2/_/_/package/be4c8261869726f21e2b0dcec6af3918a41bbacd/lib/libopencv_imgproc.a
>>> referenced by color_hsv.dispatch.cpp
>>>               color_hsv.dispatch.cpp.o:(TegraCvtColor_bgr2hsv_Invoker::operator()(cv::Range const&) const) in archive /home/build-user/.conan/data/opencv/4.5.2/_/_/package/be4c8261869726f21e2b0dcec6af3918a41bbacd/lib/libopencv_imgproc.a
[...]
```

</details>



Discussion:
I have a similar issue although I am cross-building from an Ubuntu x86_64 virtual machine with GCC 7.5.0
This problem is reproduced for me on armv8 native build for static linking with GCC 9.4
The problem is solved for me by changing in 'conanfile.py':
```diff
-if self.settings.os == "iOS" or self.settings.os == "Macos":
+if self.settings.os == "iOS" or self.settings.os == "Macos" or self.settings.os == "Linux":
    if not self.options.shared:
        if conan_component == "opencv_core":
            libs = list(filter(lambda x: not x.startswith("opencv"), tools.collect_libs(self)))
            self.cpp_info.components[conan_component].libs += libs
```
@MikhailUskin i hope it is okay for you, that i created a pull-request with your presented fix here. I want to get this to upsteam, so i did the work here for place the pull-request.

Resolving patch:
diff --git a/recipes/opencv/4.x/conanfile.py b/recipes/opencv/4.x/conanfile.py
--- a/recipes/opencv/4.x/conanfile.py
+++ b/recipes/opencv/4.x/conanfile.py
@@ -771,7 +771,7 @@ def add_components(components):
                             self.cpp_info.components[conan_component].libdirs.append("lib")
                             self.cpp_info.components[conan_component].libs += tools.collect_libs(self)
 
-                if self.settings.os in ["iOS", "Macos", "Linux"]:
+                if self.settings.os in ["iOS", "Macos", "Linux", "Neutrino"]:
                     if not self.options.shared:
                         if conan_component == "opencv_core":
                             libs = list(filter(lambda x: not x.startswith("opencv"), tools.collect_libs(self)))


Test patch: