Skip to content

[OpenCV 4.7.0] build failure for QNX. Patch suggestion #35209

@Arech

Description

@Arech

Operating system

host: Ubuntu20.04
cross-compiling target: QNX710

Compiler

ntoaarch64-g++ from QNX SDP 710

Steps to reproduce the behavior

in dependencies of vcpkg.json

{
  "name": "opencv4",
  "default-features": false,
  "features": ["jpeg","png","tiff","ffmpeg"]
}

baseline is 1e334d770ac71a89d1c36d51019e60dd08b68f76 (OpenCV 4.7.0#6)

Failure logs

Several issues due to incompatibilities with QNX, didn't save the log, sorry, please see patch suggestion below

Additional context

After making an override port for ffmpeg with the patch from #35208 applied (warning: it's not the ffmpeg version used for this baseline, though patch will most likely be the same), the following patch is needed for baseline 1e334d770ac71a89d1c36d51019e60dd08b68f76 OpenCV 4.7.0#6 to make it cross-compile to QNX and make OpenCV based apps work (at least to the scope tested)

diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp
index 027072a5da..ae7a249b3e 100644
--- a/modules/core/src/system.cpp
+++ b/modules/core/src/system.cpp
@@ -131,11 +131,15 @@ void* allocSingletonNewBuffer(size_t size) { return malloc(size); }
 #include <cstdlib>        // std::abort
 #endif
 
-#if defined __ANDROID__ || defined __unix__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__ || defined __Fuchsia__
+#if defined __ANDROID__ || defined __unix__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__ || defined __Fuchsia__ || defined __QNX__
 #  include <unistd.h>
 #  include <fcntl.h>
 #if defined __QNX__
 #  include <sys/elf.h>
+#  include <sys/auxv.h>
+using Elf64_auxv_t = auxv64_t;
+#  include <elfdefinitions.h>
+constexpr decltype(auto) AT_HWCAP = NT_GNU_HWCAP;
 #else
 #  include <elf.h>
 #endif

A few comments:

  • QNX has __unix__ undefined and it requires it's own __QNX__ macro to be tested
  • Elf64_auxv_t data type isn't defined anywhere in QNX SDP 710 files. auxv64_t seems to be a perfect replacement, but I'm not an expert on this.
  • AT_HWCAP value is also never defined for QNX. NT_GNU_HWCAP seems to be closest semantical equivalent, but I have no sound grounds under this. Someone more familiar with QNX should verify that.

Anyway, this change to 1e334d770ac71a89d1c36d51019e60dd08b68f76 OpenCV 4.7.0#6 makes it cross-compile successfully. Several apps that rely on OpenCV image&video stream readers + some image processing works nicely in QNX.

disclaimer: I didn't run neither ffmpeg nor OpenCV tests after fixing ports. It's our own tests that show that it works as expected.

Metadata

Metadata

Assignees

Labels

category:port-featureThe issue is with a library, which is requesting new capabilities that didn’t exist

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions