Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/2] package/opencv: fix static linking
Date: Thu, 11 May 2017 23:41:07 +0200	[thread overview]
Message-ID: <20170511234107.09db2b36@free-electrons.com> (raw)
In-Reply-To: <20170419101142.13051-2-bernd.kuhls@t-online.de>

Samuel,

Could you review the below patch please?

Thanks!

Thomas

On Wed, 19 Apr 2017 12:11:42 +0200, Bernd Kuhls wrote:
> Fixes ffmpeg static linking
> http://autobuild.buildroot.net/results/7e6/7e67d7e6e33b52ce7fbb9cb180b2b9b19e116eee/
> 
> Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
> ---
>  ...enCVGenPkgconfig.cmake-fix-static-linking.patch | 60 ++++++++++++++++++++++
>  1 file changed, 60 insertions(+)
>  create mode 100644 package/opencv/0004-cmake-OpenCVGenPkgconfig.cmake-fix-static-linking.patch
> 
> diff --git a/package/opencv/0004-cmake-OpenCVGenPkgconfig.cmake-fix-static-linking.patch b/package/opencv/0004-cmake-OpenCVGenPkgconfig.cmake-fix-static-linking.patch
> new file mode 100644
> index 000000000..1f49dd8b4
> --- /dev/null
> +++ b/package/opencv/0004-cmake-OpenCVGenPkgconfig.cmake-fix-static-linking.patch
> @@ -0,0 +1,60 @@
> +From 7969a6c89a4144216654de5419999a5a04c18c64 Mon Sep 17 00:00:00 2001
> +From: Bernd Kuhls <bernd.kuhls@t-online.de>
> +Date: Wed, 19 Apr 2017 11:26:00 +0200
> +Subject: [PATCH 1/1] cmake/OpenCVGenPkgconfig.cmake: fix static linking
> +
> +https://github.com/opencv/opencv/commit/671a630f47635ee8e44daf5ae6e94969ac4b8e0f#diff-9076fba682f6d51a018b6de8648e1cdb
> +updated the code to create opencv.pc to fix build errors in buildroot.
> +
> +In case of static-only builds with glib-enabled qt this however creates
> +a broken opencv.pc because libname gets truncated from libglib-2.0.a to
> +libglib-2, same is valid for libgobject-2.0.a and libgthread-2.0.a.
> +
> +CMake get_filename_component removes all extensions from the filename
> +https://cmake.org/cmake/help/v3.0/command/get_filename_component.html
> +which is too much for our use-case.
> +
> +opencv.pc currently contains -lgobject-2 -lglib-2 -lgthread-2, linking
> +against these libs will fail, for example in ffmpeg, because the files
> +do not exist:
> +http://autobuild.buildroot.net/results/7e6/7e67d7e6e33b52ce7fbb9cb180b2b9b19e116eee/build-end.log
> +
> +Quoting ffmpeg configure.log:
> +
> +i586-buildroot-linux-musl/bin/ld: cannot find -lgobject-2
> +i586-buildroot-linux-musl/bin/ld: cannot find -lglib-2
> +i586-buildroot-linux-musl/bin/ld: cannot find -lgthread-2
> +
> +Instead of using get_filename_component we need a function which only
> +strips the last extension, copied from openjpeg:
> +
> +https://github.com/uclouvain/openjpeg/commit/820c04c6799ea38aacd4e5d637073e6ab1ec643c#diff-53c915af197ccc28c0551ce6aae49af7R53
> +
> +Patch sent upstream: https://github.com/opencv/opencv/pull/8611
> +
> +Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
> +---
> + cmake/OpenCVGenPkgconfig.cmake | 7 ++++++-
> + 1 file changed, 6 insertions(+), 1 deletion(-)
> +
> +diff --git a/cmake/OpenCVGenPkgconfig.cmake b/cmake/OpenCVGenPkgconfig.cmake
> +index 4c46e66f4..d4eb9b6d3 100644
> +--- a/cmake/OpenCVGenPkgconfig.cmake
> ++++ b/cmake/OpenCVGenPkgconfig.cmake
> +@@ -74,7 +74,12 @@ if(OpenCV_EXTRA_COMPONENTS)
> +       list(APPEND OpenCV_LIB_COMPONENTS_ "${extra_component}")
> +     elseif(extra_component MATCHES "[\\/]")
> +       get_filename_component(libdir "${extra_component}" PATH)
> +-      get_filename_component(libname "${extra_component}" NAME_WE)
> ++# cannot use longest extension function, since some libnames contain
> ++# multiple dots, like libglib-2.0.a.
> ++# Instead write out own shortest extension function:
> ++      get_filename_component(libname "${extra_component}" NAME)
> ++      string(FIND ${libname} "." SHORTEST_EXT_POS REVERSE)
> ++      string(SUBSTRING ${libname} 0 ${SHORTEST_EXT_POS} libname)
> +       string(REGEX REPLACE "^lib" "" libname "${libname}")
> +       list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libdir}" "-l${libname}")
> +     else()
> +-- 
> +2.11.0
> +



-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

  reply	other threads:[~2017-05-11 21:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19 10:11 [Buildroot] [PATCH 1/2] package/opencv: bump version to 2.4.13.2 Bernd Kuhls
2017-04-19 10:11 ` [Buildroot] [PATCH 2/2] package/opencv: fix static linking Bernd Kuhls
2017-05-11 21:41   ` Thomas Petazzoni [this message]
2017-05-02 20:50 ` [Buildroot] [PATCH 1/2] package/opencv: bump version to 2.4.13.2 Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170511234107.09db2b36@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox