Open Source Computer Vision Library
Go to file
Samuel Martin 671a630f47 cmake/OpenCVGenPkgconfig.cmake: rework opencv.pc generation
Using absolute path to locate the components in the "Libs:" field of the
*.pc can badly break cross-compilation, especially when building
statically linked objects.

Indeed, pkg-config automatically replaces the '-I...' and '-L...' paths
when the PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_LIBDIR environment
variables are set [1]. This feature is very helpful and common in
cross-compilation framework like Buildroot [2,3].

When there are absolute paths in the *.pc files, pkg-config won't be
able to do the path substitutions for these paths when the
aforementioned environment variables are set.
In such case, since the prefix is the target one, not the sysroot one,
these libraries' absolute paths will point to:
- in the best case: a non-existing file (i.e. these files do not exists
  on the host system;
- at worst: the host system's libraries. This will make the linking
  failed because these host system's libraries will most likely not be
  build for the target architecture [4].

So, this patch replace the components' absolute paths by the form:
  -L<libdir> -l<libname>

This way, the linker will be able to resolve each dependency path,
whatever the kind of objects/build (shared object or static build) it
is dealing with.

Note that for static link, the library order does matter [5]. The order
of the opencv components has been carefully chosen to comply with this
requirement.

Fixes #3931

This patch is a port of [6] on the master branch.

[1] http://linux.die.net/man/1/pkg-config
[2] http://buildroot.org/
[3] http://git.buildroot.net/buildroot/tree/package/pkgconf/pkg-config.in
[4] http://autobuild.buildroot.net/results/e8a/e8a859276db34aff87ef181b0cce98916b0afc90/build-end.log
[5] http://stackoverflow.com/questions/45135/linker-order-gcc
[6] eceada586b

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
2015-05-22 16:09:05 +03:00
3rdparty make sure opencv builds fine with the recent versions of libav (e.g. from Ubuntu 14.10) 2015-04-22 21:57:29 +03:00
apps fixed vector out of range exception in nextImg 2015-05-18 13:29:15 -07:00
cmake cmake/OpenCVGenPkgconfig.cmake: rework opencv.pc generation 2015-05-22 16:09:05 +03:00
data remove example_blob.bmp 2015-05-13 18:06:26 +02:00
doc Reorganized user guide 2015-05-13 18:46:21 +03:00
include Added cmake option for abi descriptor generating (GENERATE_ABI_DESCRIPTOR) 2015-03-17 16:04:04 +03:00
modules Merge pull request #4025 from vpisarev:features2d_fixes 2015-05-21 19:16:27 +00:00
platforms Rename manager package to OpenCV3 Manager 2015-04-17 16:59:52 +03:00
samples VideoCapture with digital camera and gPhoto2 library 2015-05-21 00:41:39 +02:00
.gitattributes Made changes to OpenCVFindMatlab suggested by SpecLad 2013-09-14 13:32:15 +10:00
.gitignore Added support for 'imgcodecs' module: 2015-03-31 16:31:37 +03:00
.tgitconfig Add tgit.icon project config 2014-02-26 17:46:52 +08:00
CMakeLists.txt VideoCapture with digital camera and gPhoto2 library 2015-05-21 00:41:39 +02:00
LICENSE 1. Input/OutputArray optimizations; 2015-04-07 16:44:26 +03:00
README.md Replaced Gittip button 2014-02-15 13:10:09 +04:00

OpenCV: Open Source Computer Vision Library

Gittip

Resources

Contributing

Please read before starting work on a pull request: http://code.opencv.org/projects/opencv/wiki/How_to_contribute

Summary of guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.