Skip to contentSkip to conversation

package/opencv3: allow to use pkg-config while cross-compiling

PATCH New Romain Naour 3 participants 3 messages Jul 23, 2019 – Aug 4, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/opencv3: allow to use pkg-config while cross-compiling

Since version 3.4.1 [1], opencv disable pkg-config while cross-compiling to avoid host headers/libraries poisoning.

Due to this, opencv fail to detect ffmpeg, gstreamer and gtk dependencies
even if the corresponding support is requested by
BR2_PACKAGE_OPENCV3_WITH_{FFMPEG,GSTREAMER,GTK2,GTK3}.

Maybe other dependencies are affected by this issue...

While configuring opencv we can notice the following messages:
"-- OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT" "-- Can't find ffmpeg - 'pkg-config' utility is missing"

As the result ffmpeg and gstreamer are not enabled:
-- Video I/O:

--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   NO
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h

We can fixes this by adding a new option OPENCV_ENABLE_PKG_CONFIG=ON

-- Video I/O:

--     FFMPEG:                      YES
--       avcodec:                   YES (ver 58.35.100)
--       avformat:                  YES (ver 58.20.100)
--       avutil:                    YES (ver 56.22.100)
--       swscale:                   YES (ver 5.3.100)
--       avresample:                YES (ver 4.0.0)
--     GStreamer:
--       base:                      YES (ver 1.16.0)
--       video:                     YES (ver 1.16.0)
--       app:                       YES (ver 1.16.0)
--       riff:                      YES (ver 1.16.0)
--       pbutils:                   YES (ver 1.16.0)
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h

Add host-pkgconf in the dependencies.

If there is a path poisoning issue, it will be detected by the toolchain paranoid wrapper.

[1] https://github.com/opencv/opencv/commit/c4f9ff0285130bd8bcf9d87a9ea6949bdd7e9e5d

Cc Samuel Martin <[email protected]>
Cc Fabrice Fontaine <[email protected]>
Cc Bernd Kuhls <[email protected]>

---
This patch should be backported to Buildroot 2019.02 that use opencv 3.4.2.

---
 package/opencv3/opencv3.mk | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
package/opencv3/opencv3.mk +3 -2
index 7fa9a6e8a5..6046f159af 100644
@@ -34,7 +34,8 @@ OPENCV3_CONF_OPTS += \
 	-DBUILD_PERF_TESTS=$(if $(BR2_PACKAGE_OPENCV3_BUILD_PERF_TESTS),ON,OFF) \
 	-DBUILD_TESTS=$(if $(BR2_PACKAGE_OPENCV3_BUILD_TESTS),ON,OFF) \
 	-DBUILD_WITH_DEBUG_INFO=OFF \
-	-DDOWNLOAD_EXTERNAL_TEST_DATA=OFF
+	-DDOWNLOAD_EXTERNAL_TEST_DATA=OFF \
+	-DOPENCV_ENABLE_PKG_CONFIG=ON
 
 ifeq ($(BR2_PACKAGE_OPENCV3_BUILD_TESTS)$(BR2_PACKAGE_OPENCV3_BUILD_PERF_TESTS),)
 OPENCV3_CONF_OPTS += -DINSTALL_TEST=OFF
@@ -225,7 +226,7 @@ OPENCV3_CONF_OPTS += \
 	-DWITH_WEBP=OFF \
 	-DWITH_XINE=OFF
 
-OPENCV3_DEPENDENCIES += zlib
+OPENCV3_DEPENDENCIES += host-pkgconf zlib
 
 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_FFMPEG),y)
 OPENCV3_CONF_OPTS += -DWITH_FFMPEG=ON
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 package/opencv3: allow to use pkg-config while cross-compiling

Quoted 54 lines · On Tue, 23 Jul 2019 21:50:40 +0200 Romain Naour <[email protected]> wrote:

Since version 3.4.1 [1], opencv disable pkg-config while cross-compiling to avoid host headers/libraries poisoning.

Due to this, opencv fail to detect ffmpeg, gstreamer and gtk dependencies
even if the corresponding support is requested by
BR2_PACKAGE_OPENCV3_WITH_{FFMPEG,GSTREAMER,GTK2,GTK3}.

Maybe other dependencies are affected by this issue...

While configuring opencv we can notice the following messages:
"-- OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT" "-- Can't find ffmpeg - 'pkg-config' utility is missing"

As the result ffmpeg and gstreamer are not enabled:
-- Video I/O:

--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   NO
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h

We can fixes this by adding a new option OPENCV_ENABLE_PKG_CONFIG=ON

-- Video I/O:

--     FFMPEG:                      YES
--       avcodec:                   YES (ver 58.35.100)
--       avformat:                  YES (ver 58.20.100)
--       avutil:                    YES (ver 56.22.100)
--       swscale:                   YES (ver 5.3.100)
--       avresample:                YES (ver 4.0.0)
--     GStreamer:
--       base:                      YES (ver 1.16.0)
--       video:                     YES (ver 1.16.0)
--       app:                       YES (ver 1.16.0)
--       riff:                      YES (ver 1.16.0)
--       pbutils:                   YES (ver 1.16.0)
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h

Add host-pkgconf in the dependencies.

If there is a path poisoning issue, it will be detected by the toolchain paranoid wrapper.

[1] https://github.com/opencv/opencv/commit/c4f9ff0285130bd8bcf9d87a9ea6949bdd7e9e5d

Cc Samuel Martin <[email protected]>
Cc Fabrice Fontaine <[email protected]>
Cc Bernd Kuhls <[email protected]>
Quoted 5 lines

---
This patch should be backported to Buildroot 2019.02 that use opencv 3.4.2.

---
 package/opencv3/opencv3.mk | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 package/opencv3: allow to use pkg-config while cross-compiling

In reply to Romain Naour
Quoted 50 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Romain" == Romain Naour <[email protected]> writes:

Since version 3.4.1 [1], opencv disable pkg-config while cross-compiling to avoid host headers/libraries poisoning.

Due to this, opencv fail to detect ffmpeg, gstreamer and gtk dependencies
even if the corresponding support is requested by
BR2_PACKAGE_OPENCV3_WITH_{FFMPEG,GSTREAMER,GTK2,GTK3}.

Maybe other dependencies are affected by this issue...

While configuring opencv we can notice the following messages:
"-- OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT" "-- Can't find ffmpeg - 'pkg-config' utility is missing"

As the result ffmpeg and gstreamer are not enabled:
-- Video I/O:

--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   NO
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h

We can fixes this by adding a new option OPENCV_ENABLE_PKG_CONFIG=ON

-- Video I/O:

--     FFMPEG:                      YES
--       avcodec:                   YES (ver 58.35.100)
--       avformat:                  YES (ver 58.20.100)
--       avutil:                    YES (ver 56.22.100)
--       swscale:                   YES (ver 5.3.100)
--       avresample:                YES (ver 4.0.0)
--     GStreamer:
--       base:                      YES (ver 1.16.0)
--       video:                     YES (ver 1.16.0)
--       app:                       YES (ver 1.16.0)
--       riff:                      YES (ver 1.16.0)
--       pbutils:                   YES (ver 1.16.0)
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h

Add host-pkgconf in the dependencies.

If there is a path poisoning issue, it will be detected by the toolchain paranoid wrapper.

Quoted 8 lines

[1] https://github.com/opencv/opencv/commit/c4f9ff0285130bd8bcf9d87a9ea6949bdd7e9e5d

Cc Samuel Martin <[email protected]>
Cc Fabrice Fontaine <[email protected]>
Cc Bernd Kuhls <[email protected]>

---
This patch should be backported to Buildroot 2019.02 that use opencv 3.4.2.

Committed to 2019.02.x and 2019.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard