Thanks to visit codestin.com
Credit goes to github.com

Skip to content

When linking against libpng/zlib on Windows, use upstream lib names. #13084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ install:
# Let the install prefer the static builds of the libs
- set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib
- mkdir lib || cmd /c "exit /b 0"
- copy /y %LIBRARY_LIB%\zlibstatic.lib lib\z.lib
- copy /y %LIBRARY_LIB%\libpng_static.lib lib\png.lib
- copy /y %LIBRARY_LIB%\zlibstatic.lib lib\zlib.lib
- copy /y %LIBRARY_LIB%\libpng16_static.lib lib\libpng16.lib
# These z.lib / png.lib are not static versions but files which end up as
# dependencies to the dll file. This is fine for the conda build, but not here
# and for the wheels
Expand Down
4 changes: 2 additions & 2 deletions build_alllocal.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ IF NOT DEFINED CONDA_PREFIX (
:: copy the libs which have "wrong" names
set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib
mkdir lib || cmd /c "exit /b 0"
copy %LIBRARY_LIB%\zlibstatic.lib lib\z.lib
copy %LIBRARY_LIB%\libpng_static.lib lib\png.lib
copy %LIBRARY_LIB%\zlibstatic.lib lib\zlib.lib
copy %LIBRARY_LIB%\libpng16_static.lib lib\libpng16.lib

:: build the target
python setup.py %TARGET%
19 changes: 19 additions & 0 deletions doc/api/next_api_changes/2019-01-02-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Changes to the Windows build
````````````````````````````

Previously, when building the :mod:`matplotlib._png` extension, the build
script would add "png" and "z" to the extensions ``.libraries`` attribute (if
pkg-config information is not available, which is in particular the case on
Windows).

In particular, this implies that the Windows build would look up files named
``png.lib`` and ``z.lib``; but neither libpng upstream nor zlib upstream
provides these files by default. (On Linux, this would look up ``libpng.so``
and ``libz.so``, which are indeed standard names.)

Instead, on Windows, we now look up ``libpng16.lib`` and ``zlib.lib``, which
*are* the upstream names for the shared libraries (as of libpng 1.6.x).

For a statically-linked build, the upstream names are ``libpng16_static.lib``
and ``zlibstatic.lib``; one still needs to manually rename them if such a build
is desired.
8 changes: 7 additions & 1 deletion setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,13 @@ def get_extension(self):
ext, 'libpng',
atleast_version='1.2',
alt_exec=['libpng-config', '--ldflags'],
default_libraries=['png', 'z'])
default_libraries=(
['png', 'z'] if os.name == 'posix' else
# libpng upstream names their lib libpng16.lib, not png.lib.
# zlib upstream names their lib zlib.lib, not z.lib.
['libpng16', 'zlib'] if os.name == 'nt' else
[]
))
add_numpy_flags(ext)
return ext

Expand Down