I'm trying to build libpng which has worked up to a point.
I'm using Windows XP, and have a MingW compiler. I also have MSYS installed and am using it to configure libpng.

The issue I'm having is that libpng can't find zlib. I've tried every variation under the sun and still can't get libpng to see zlib. The error at the end of the configuration process is

zlibVersion in -lz....no
z_zlibVersion in -lz....no
error: zlib not installed

The installation file tells me to do this. So I could have interpreted it wrong but I've tried everything from renaming the zlib directory to placing it in the libjpeg directory and then again in side the libjpeg/scripts directory. I've also copied the zlib.h and zconf.h file from the zlib directory and put it in the libjpeg directory but still the same error... I think I'm primarily here to find these problems. I can see allot of complaints on the internet about this but none of the answers make sense to me. Here is what the Installation file says.. Any clues as to where I'm going wrong?

    If your system already has a preinstalled zlib you will still need
to have access to the zlib.h and zconf.h include files that
correspond to the version of zlib that's installed.

You can rename the directories that you downloaded (they
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.5"
or "zlib125") so that you have directories called "zlib" and "libpng".

Your directory structure should look like this:

   ..       (the parent directory)
      libpng  (this directory)
          INSTALL (this file)
          README
          *.h
          *.c
          CMakeLists.txt    =>  "cmake" script
          configuration files:
             configure.ac, configure, Makefile.am, Makefile.in,
             autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
             libpng-config.in, aclocal.m4, config.h.in, config.sub,
             depcomp, install-sh, mkinstalldirs, test-pngtest.sh
          contrib
             gregbook
             pngminim
             pngminus
             pngsuite
             visupng
          projects
             visualc71
             vstudio
          scripts
             makefile.*
             *.def (module definition files)
             etc.
          pngtest.png
          etc.
      zlib
          README
          *.h
          *.c
          contrib
          etc.

Just to add to this, I tried dumping the entire zlib contents into the libpng directory and still.... libpng can't find zlib?

Does anyone know how to make this work? If I enter ./configure into MSYS then everything works but it can't find zlib and says zlib is not installed. There must be some pre-requisites for libpng to be set up for building with zlib but I'm not sure how to find out what they are?

IMHO, trying to build libpng with the MingW compiler is little more than a lesson in futility. I found a lot of "solutions" on the internet. But I could never get any solution to successfully build libpng.

I did notice that libpng has a MS Visual Studio project in the projects\vstudio folder. So, I used MS Visual Studio 21010 Express to build libpng AND Zlib successfully.

Bottom line, you may wish to consider this option as opposed to using MingW.

You're right about the difficulties in compiling with MINGW. The strange thing is, libpng has a gcc makefile which has me a little astonished that it still won't compile.

When I do try to compile using the command prompt it gives me this error. Does this mean anything to you? .... ALSO.. At the top of the makefile I can set the directory for zlib but I'm not sure how? Do I do this = "C:\zlib" in quotes or C:\zlib without quotes ?

Here's the error I get:

C:\libpng>mingw32-make -f scripts\makefile.gcc

\\ERROR BELOW
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
process_begin: CreateProcess(NULL, cp scripts/pnglibconf.h.prebuilt pnglibconf.h
, ...) failed.
make (e=2): The system cannot find the file specified.
mingw32-make: *** [pnglibconf.h] Error 2

C:\libpng>

ok, if I input the command I usually put into the Windows XP command prompt by actually butting that prompt into MSYS it seems to compile. There's only a short list of files but it doesn't come up with any error. I'm dumfounded as to why I can't use the command prompt with the same command.
Here's what I put in.

mingw32-make -f scripts\makefile.gcc

Why would that work in MSYS and not the windows command prompt.
My fear is that I've been deceived.. maybe it hasn't built properly even though it seems to have? Any clues.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.