Skip to content

fix link order: put zlib after png/tiff/openexr#19515

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
zchrissirhcz:3.4-fix-mislinked-zlib-in-vcpkg-by-adjust-link-order
Feb 12, 2021
Merged

fix link order: put zlib after png/tiff/openexr#19515
opencv-pushbot merged 1 commit intoopencv:3.4from
zchrissirhcz:3.4-fix-mislinked-zlib-in-vcpkg-by-adjust-link-order

Conversation

@zchrissirhcz
Copy link
Copy Markdown
Contributor

Previous link dependency: imgcodecs --> zlib --> libpng
this can generate imgcodecs shared lib, until Visual Studio integrated
with vcpkg, which will additionally specify LIBPATH, pointing to vcpkg
installed zlib (if any), which links the wrong zlib.

Fixed link dependency: imgcodecs --> libpng --> zlib
in this fixed case, symbols in zlib referenced in libpng will be found
in the build-from-source static zlib, instead of the vcpkg one.

related discussion:

MSVC linking order reference pages:

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Previous link dependency: imgcodecs --> zlib --> libpng
this can generate imgcodecs shared lib, until Visual Studio integrated
with vcpkg, which will additionally specify LIBPATH, pointing to vcpkg
installed zlib (if any), which links the wrong zlib.

Fixed link dependency: imgcodecs --> libpng --> zlib
in this fixed case, symbols in zlib referenced in libpng will be found
in the build-from-source static zlib, instead of the vcpkg one.

related discussion:
- microsoft/vcpkg#16165
- opencv#17051
- opencv#10576

MSVC linking order reference pages:
- https://docs.microsoft.com/en-us/cpp/build/reference/link-input-files?view=msvc-160
  for link order
- https://docs.microsoft.com/en-us/cpp/build/reference/linking?view=msvc-160
  LIB environment variable, for library file searching
- https://docs.microsoft.com/en-us/cpp/build/reference/libpath-additional-libpath?view=msvc-160
  LIBPATH option, for library file searching
@zchrissirhcz
Copy link
Copy Markdown
Contributor Author

Previously PR (#19154) seems rebase wrong. Thus create this one.

Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Well done!

@opencv-pushbot opencv-pushbot merged commit fba70f7 into opencv:3.4 Feb 12, 2021
@alalek alalek mentioned this pull request Feb 12, 2021
@alalek alalek mentioned this pull request Apr 9, 2021
@zchrissirhcz zchrissirhcz deleted the 3.4-fix-mislinked-zlib-in-vcpkg-by-adjust-link-order branch April 19, 2021 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants