Skip to content
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

Windows 11: ld.exe: cannot find -lz: No such file or directory #90

Open
hakonhagland opened this issue Dec 15, 2022 · 1 comment
Open

Comments

@hakonhagland
Copy link

I have installed a debug version of perl 5.37.6 on Windows 11 using MinGW-w64 and gcc 11.3 from https://winlibs.com/ (using the MSVCRT runtime library), see Perl/perl5#20395 for more information on this.

After applying the fix in #88 (or #89) I get the following

>perl Makefile.PL
C:\perl-debug\bin\perl.exe is installed in c:\perl-debug\lib okay
PPM for perl5.037006
Test Compiling config/perlrx.c
Test Compiling config/pmop.c
[...]
Finding dependencies for tkGlue_f.c
Finding dependencies for tkWin32Dll.c
Tests in PNG
Tests in JPEG
Tests in Event
Generating a gmake-style Makefile
Writing Makefile for Tk
Writing MYMETA.yml and MYMETA.json

>gmake
makefile:1022: warning: ignoring old recipe for target 'MANIFEST'
cd pTk && gmake DEFINE="" LIBPERL_A="libperl.a" LINKTYPE="dynamic" OPTIMIZE="-ggdb -O0" PREFIX="c:\perl-debug\site" PASTHRU_DEFINE=" " PASTHRU_INC="-I. -I./pTk/mTk/xlib "
gmake[1]: Entering directory 'C:/Users/hakon/perl/github/perl-tk/pTk'
gcc -c -I. -I./pTk/mTk/xlib  -I.. -I.. -I../pTk/mTk/xlib -I. -Ibitmaps -I.. -I../pTk/mTk/xlib -DWIN32 -DWIN64 -DDEBUGGING -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -DPERLDLL -ggdb -O0   -DVERSION=\"804.036\" -DXS_VERSION=\"804.036\"  "-IC:\perl-debug\lib\CORE"    imgInt_f.c
gcc -c -I. -I./pTk/mTk/xlib  -I.. -I.. -I../pTk/mTk/xlib -I. -Ibitmaps -I.. -I../pTk/mTk/xlib -DWIN32 -DWIN64 -DDEBUGGING -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -DPERLDLL -ggdb -O0   -DVERSION=\"804.036\" -DXS_VERSION=\"804.036\"  "-IC:\perl-debug\lib\CORE"    imgObj.c
gcc -c -I. -I./pTk/mTk/xlib  -I.. -I.. -I../pTk/mTk/xlib -I. -Ibitmaps -I.. -I../pTk/mTk/xlib -DWIN32 -DWIN64 -DDEBUGGING -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -DPERLDLL -ggdb -O0   -DVERSION=\"804.036\" -DXS_VERSION=\"804.036\"  "-IC:\perl-debug\lib\CORE"    imgUtil.c
[...]
gmake[1]: Entering directory 'C:/Users/hakon/perl/github/perl-tk/PNG'
cp PNG.pm ..\blib\lib\Tk\PNG.pm
cd zlib && gmake libz.a "CC=gcc  "
gmake[2]: Entering directory 'C:/Users/hakon/perl/github/perl-tk/PNG/zlib'
gmake[2]: 'libz.a' is up to date.
gmake[2]: Leaving directory 'C:/Users/hakon/perl/github/perl-tk/PNG/zlib'
gmake[2]: Entering directory 'C:/Users/hakon/perl/github/perl-tk/PNG/libpng'
Makefile:45: You haven't specified a 'prefix=' location. Defaulting to "/usr"
gcc   -static -Wall -O3 -funroll-loops -fomit-frame-pointer  pngtest.o -L. -lpng -L/usr/lib -lz -o pngtest-stat.exe
c:/winlibs64-gcc11.3-msvcrt/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find 
-lz: No such file or directory
collect2.exe: error: ld returned 1 exit status
gmake[2]: *** [Makefile:187: pngtest-stat.exe] Error 1
gmake[2]: Leaving directory 'C:/Users/hakon/perl/github/perl-tk/PNG/libpng'
gmake[1]: *** [Makefile:515: subdirs] Error 2
gmake[1]: Leaving directory 'C:/Users/hakon/perl/github/perl-tk/PNG'
gmake: *** [makefile:762: subdirs] Error 2

The complete log files: perl-makefile-log.txt, and gmake.log.txt

I checked that libz.a exists:

>dir PNG\zlib\libz.a
 Volume in drive C is OS
 Volume Serial Number is 0A36-53BF

 Directory of C:\Users\hakon\perl\github\perl-tk\PNG\zlib

25/10/2022  14:06           102,406 libz.a
               1 File(s)        102,406 bytes
               0 Dir(s)  136,013,594,624 bytes free

Note that the command that fails is this:

gcc   -static -Wall -O3 -funroll-loops -fomit-frame-pointer  pngtest.o -L. -lpng -L/usr/lib -lz -o pngtest-stat.exe

which is run from directory PNG\libpng. Notice that the command uses -L/usr/lib (which does not exist on Windows). It should have used something like -L../zlib, right?

@eserte
Copy link
Owner

eserte commented Dec 18, 2022

It is quite possible that the old bundled zlib causes problems, and in fact I don't know if it worked on Windows since 2007 or so. On StrawberryPerl systems libpng is already available so there's no need for neither the bundled libpng nor zlib. Maybe that would be a better option for you now --- independently build and install libpng.

Probably it would be better if Tk used Alien::PNG or so as a fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants