I'm trying to install podofo (pdf library) for use with MingW in Windows XP. It requires zlib.
I'm using CMAKE to generate the makefile.
For some reason, CMAKE, no matter how many times i redirect the ZLIB_LIBRARY to the zlib directory an error in CMAKE occurs telling me that it can't find ZLIB_LIBRARY.

Any clues as to why.????

Recommended Answers

All 20 Replies

I think I see where this may be going wrong.. Would anyone know how to 'BUILD' a 'Debug' and 'Release' version of zlib using a MingW compiler.

I'm currently inputting the cmd entry mingw32-make -f win32\Makefile.gcc and it seems to build without error but in the next step where I 'BUILD', it needs ZLIB and tells me it can't find the ZLIB_LIBRARY because it seems to be looking for a Debug and Release version.

How do I modify this command mingw32-make -f win32\Makefile.gcc to create a debug and release build for zlib..?

Thanks

Would anyone know how to 'BUILD' a 'Debug' and 'Release' version of zlib using a MingW compiler

I believe the Release version is the default build version. Have you tried adding -DDEBUG to the CFLAGS variable in the makefile to build the debug version?

Have you tried adding -DDEBUG to the CFLAGS variable in the makefile to build the debug version?

Whats that? I have no idea how to do this. Where can I read up on this sort of thing.

There must be someone out there who knows something about this sort of thing?

Here is a list of all the files in my ZLIB Directory.. Any clues as to which one is to be referenced as a ZLIB_LIBRARY ?

17/10/2012 11:05 PM <DIR> .
17/10/2012 11:05 PM <DIR> ..
10/09/2011 04:15 PM 4,968 adler32.c
17/10/2012 09:01 PM 1,332 adler32.o
17/10/2012 08:57 PM <DIR> amiga
17/10/2012 08:57 PM <DIR> as400
02/05/2012 09:12 PM 73,286 ChangeLog
29/04/2012 09:20 PM 7,227 CMakeLists.txt
11/12/2005 11:27 AM 2,520 compress.c
17/10/2012 09:01 PM 1,052 compress.o
01/05/2012 09:17 PM 25,985 configure
17/10/2012 08:57 PM <DIR> contrib
29/04/2012 04:18 PM 13,174 crc32.c
29/04/2012 04:18 PM 30,562 crc32.h
17/10/2012 09:01 PM 10,526 crc32.o
12/02/2012 05:15 PM 71,392 deflate.c
13/01/2012 10:54 PM 12,787 deflate.h
17/10/2012 09:01 PM 15,814 deflate.o
17/10/2012 08:57 PM <DIR> doc
17/10/2012 09:01 PM 75,776 example.exe
17/10/2012 09:01 PM 9,472 example.o
17/10/2012 08:57 PM <DIR> examples
17/10/2012 09:01 PM 12,800 example_d.exe
27/11/2011 03:15 PM 16,573 FAQ
13/02/2010 05:12 PM 678 gzclose.c
17/10/2012 09:01 PM 454 gzclose.o
17/03/2012 09:45 PM 6,029 gzguts.h
18/03/2012 02:52 PM 15,825 gzlib.c
17/10/2012 09:01 PM 4,729 gzlib.o
18/02/2012 03:15 PM 18,518 gzread.c
17/10/2012 09:01 PM 4,655 gzread.o
03/03/2012 10:28 AM 15,817 gzwrite.c
17/10/2012 09:01 PM 3,594 gzwrite.o
11/03/2012 10:16 AM 1,988 INDEX
18/12/2011 11:39 AM 22,701 infback.c
17/10/2012 09:01 PM 8,479 infback.o
18/04/2010 09:16 PM 13,439 inffast.c
18/04/2010 09:16 PM 427 inffast.h
17/10/2012 09:01 PM 2,768 inffast.o
05/10/2011 08:32 PM 6,332 inffixed.h
12/02/2012 03:20 PM 52,982 inflate.c
25/12/2009 05:32 PM 6,399 inflate.h
17/10/2012 09:01 PM 15,317 inflate.o
12/02/2012 05:15 PM 13,032 inftrees.c
18/04/2010 09:15 PM 2,928 inftrees.h
17/10/2012 09:01 PM 3,326 inftrees.o
17/10/2012 09:01 PM 89,408 libz.a
17/10/2012 09:01 PM 45,552 libz.dll.a
09/09/2011 11:33 PM 100 Makefile
22/04/2012 10:58 PM 9,004 Makefile.in
09/03/2012 07:43 PM 26,402 make_vms.com
17/10/2012 09:01 PM 71,680 minigzip.exe
17/10/2012 09:01 PM 4,304 minigzip.o
17/10/2012 09:01 PM 9,216 minigzip_d.exe
17/10/2012 08:57 PM <DIR> msdos
17/10/2012 08:57 PM <DIR> nintendods
17/10/2012 08:57 PM <DIR> old
17/10/2012 11:05 PM 0 print.txt
17/10/2012 08:57 PM <DIR> qnx
12/02/2012 05:15 PM 5,185 README
17/10/2012 08:57 PM <DIR> test
12/02/2012 05:15 PM 3,135 treebuild.xml
07/01/2012 03:08 PM 44,161 trees.c
18/04/2010 10:32 AM 8,472 trees.h
17/10/2012 09:01 PM 13,144 trees.o
17/01/2010 10:34 AM 1,994 uncompr.c
17/10/2012 09:01 PM 722 uncompr.o
17/10/2012 08:57 PM <DIR> watcom
17/10/2012 08:57 PM <DIR> win32
29/04/2012 04:18 PM 15,291 zconf.h
29/04/2012 04:18 PM 15,342 zconf.h.cmakein
29/04/2012 04:18 PM 15,291 zconf.h.in
02/05/2012 09:12 PM 4,235 zlib.3
02/05/2012 09:12 PM 8,760 zlib.3.pdf
02/05/2012 09:12 PM 86,717 zlib.h
02/02/2012 12:25 AM 1,119 zlib.map
11/03/2012 10:16 AM 294 zlib.pc.cmakein
17/04/2010 11:48 PM 254 zlib.pc.in
17/10/2012 09:01 PM 80,384 zlib1.dll
14/10/2006 09:45 AM 3,895 zlib2ansi
17/10/2012 09:01 PM 992 zlibrc.o
12/02/2012 03:20 PM 7,412 zutil.c
03/03/2012 01:20 AM 6,765 zutil.h
17/10/2012 09:01 PM 987 zutil.o
70 File(s) 1,185,880 bytes
14 Dir(s)

# Makefile for zlib, derived from Makefile.dj2.
# Modified for mingw32 by C. Spieler, 6/16/98.
# Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003.
# Last updated: Mar 2012.
# Tested under Cygwin and MinGW.

# Copyright (C) 1995-2003 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h

# To compile, or to compile and test, type from the top level zlib directory:
#
#   make -fwin32/Makefile.gcc;  make test testdll -fwin32/Makefile.gcc
#
# To use the asm code, type:
#   cp contrib/asm?86/match.S ./match.S
#   make LOC=-DASMV OBJA=match.o -fwin32/Makefile.gcc
#
# To install libz.a, zconf.h and zlib.h in the system directories, type:
#
#   make install -fwin32/Makefile.gcc
#
# BINARY_PATH, INCLUDE_PATH and LIBRARY_PATH must be set.
#
# To install the shared lib, append SHARED_MODE=1 to the make command :
#
#   make install -fwin32/Makefile.gcc SHARED_MODE=1

# Note:
# If the platform is *not* MinGW (e.g. it is Cygwin or UWIN),
# the DLL name should be changed from "zlib1.dll".

STATICLIB = libz.a
SHAREDLIB = zlib1.dll
IMPLIB    = libz.dll.a

#
# Set to 1 if shared object needs to be installed
#
SHARED_MODE=0

#LOC = -DASMV
#LOC = -DDEBUG -g

PREFIX =
CC = $(PREFIX)gcc
CFLAGS = $(LOC) -O3 -Wall -DDEBUG

AS = $(CC)
ASFLAGS = $(LOC) -Wall

LD = $(CC)
LDFLAGS = $(LOC)

The above is part of the ZLIB Makefile.gcc found in the Win32 folder. Please note that I have added -DDEBUG to the line that has the CFLAGS variable on it. Modify the makefile and build it to determine if it generates a debug build.

Thanks Bob, but I get an error when I try to build zlib.

gcc -03 uWall -DDEBUG -c -o compress.o compress.c
gcc: uWall: No such file or directory
mingw32-make: ***[compress.o] Error 1

Can I ask how you knew how to do that? Is that something you have learned from using cmake and if so, was it from a book or a tutorial? I'm really interested in improving my knowledge in this area given the grief it is giving me. I know there is a CMAKE tute, was it there you picked it up..

cheers.

I believe you're trying to build the application from the Win32 folder. Try building it from the Zlib-1.2.7 folder which should contain all the required source code files.

The makefile is in the Win32 folder. I change the directory in cmd prompt to the zlib folder and that is where it is build. It builds always without error but for some reason CMAKE can't see the zlib library file when I go to build the PODOFO library using cmake.

Can you see a library file or something that would qualify as a library in the list I've provided above?

Also,, just wonddering how you knew how to do those entries in the CMakeLists file?

Thanks

just wonddering how you knew how to do those entries in the CMakeLists file?

When you run CMAKE, it creates a CmakeCache.txt file. in this file are the following entries:

//Path to a file.
ZLIB_INCLUDE_DIR:PATH=ZLIB_INCLUDE_DIR-NOTFOUND

//Path to a library.
ZLIB_LIBRARY_DEBUG:FILEPATH=ZLIB_LIBRARY_DEBUG-NOTFOUND

//Path to a library.
ZLIB_LIBRARY_RELEASE:FILEPATH=ZLIB_LIBRARY_RELEASE-NOTFOUND

The entries indicate that the include, debug and release libraries were not found. Thus, the CMAKE variables ZLIB_INCLUDE_DIR, ZLIB_LIBRARY_DEBUG and ZLIB_LIBRARY_RELEASE had to be updated to point to these items.

I just realized I provided some misinformation in a previous post. I indicated that you must add -DDEBUG to the CC variable which is correct. But I also forgot to mention that you should also add -g to the CC variable. The -g adds the debug symbols to the binaries.

Thanks again. Unfortunately nothing has changed.
After building the zlib library I'm expecting to see a Debug and Release Directory inside the zlib directory but I'm not.

I can only thing that there is something wrong with the build process I'm using to build zlib. The CMAKELists file will only direct the process to what it needs so I can set the ZLIB_INCLUDE_DIR in CMAKE which I have done and it works. BUT... I also set the ZLIB_LIBRARY variable in CMAKE so the path points to the zlib directory but that doesn't work. My thoughts are as stated earlier. The Debug and Release versions aren't there (maybe I am to produce a different set of files for both or the process of building zlib is supposed to create two separate directories).

A few weeks ago I build wxWidgets in MingW and this is what I entered into the command promt.

mingw32-make -f makefile.gcc SHARED=0 UNICODE=1 MONOLITHIC=1 BUILD=release

mingw32-make -f makefile.gcc SHARED=0 UNICODE=1 MONOLITHIC=1 BUILD=debug

As you can see it creates two directories, one for release and one for debug which seems to be what CMAKE is looking for. But when I try to run this same process when building zlib, by entering the below, it doesn't work. I get the same build and it won't run a second time. It seems to completely ignore the debug and release flag. Thats my perspective anyway.. Not sure where to go to from here.

mingw32-make -f win32\Makefile.gcc BUILD=debug
mingw32-make -f win32\Makefile.gcc BUILD=release

After building the zlib library I'm expecting to see a Debug and Release Directory inside the zlib directory but I'm not.

Building the Zlib library doesn't create the Debug and Release directories. What I would suggest that you try is to create a Debug and Release folder. Next build the Release version and copy the built binaries to the Release folder. Then build the Debug version and copy all the built binaries to the Debug folder. Both the Release and Debug builds use the same binary names such as ZLIB1.dll. Normally, a D would be appended to the name to indicate a Debug build. But this isn't the case with ZLIB.

You'll notice a size difference between the Release and Debug binaries. For example, the Release ZLIB1.dll is 91,662 bytes and the Debug ZLIB1.dd is 98,830 bytes. Thus, the debugging symbols are being added to the Debug version.

Thanks Bob, but how do you build a debug version as opposed to a release version. Are you suggesting that I just build zlib twice and drop the contents into each 'debug' and 'release' folder. OR is there a special 'MAKE' syntax or Windows CMD syntax like the below?

// JUST SO YOU KNOW,THE BELOW DOESN'T WORK IN TERMS OF BUILDING TWO SEPARATE BUILDS.
// ONCE I RUN mingw32-make -f win32\Makefile.gcc BUILD=debug IT DOESN'T PRODICE A DEBUG //FOLDER OR ANYTHING LIKE THAT AND i CAN'T RUN THE RELEASE VERSION TO THE SAME DIRECTORY. 

mingw32-make -f win32\Makefile.gcc BUILD=debug
mingw32-make -f win32\Makefile.gcc BUILD=release

Are you suggesting that I just build zlib twice and drop the contents into each 'debug' and 'release' folder

Yes, that's exactly what I'm suggesting you do. There aren't any instructions in the Makefile.gcc to create either the Release or Debug folder. So, if you initially build the Release vesion and then build the Debug version, the Debug version binaries will overwrite the Release version binaries in the same folder. So, build the Release version and copy the binaries to your manually created Release folder and then build the Debug version and copy the binaries to your manually created Debug folder. The best way to build the Debug version would be to edit the Makefile.gcc and remove the pound sign from in front of the LOC macro. The pound sign just comments out this macro. Then execute the Makefile.gcc. Now you'll have to put the pound sign in front of the LOC macro to build the Release version.

Thanks Bob, did that.. Still go the below error. I'm thinking I'm close though. It has to do with this Makefile.gcc I'm sure. What is DASMV there is two LOC macro options.

Error message below: The same.

The C compiler identification is GNU 4.4.1
The CXX compiler identification is GNU 4.4.1
Check for working C compiler: C:/CodeBlocks/MinGW/bin/gcc.exe
Check for working C compiler: C:/CodeBlocks/MinGW/bin/gcc.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/CodeBlocks/MinGW/bin/g++.exe
Check for working CXX compiler: C:/CodeBlocks/MinGW/bin/g++.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
WANT_LIB64 unset; assuming normal library directory names
Will install libraries to C:/Program Files/PoDoFo/lib
Looking for strings.h
Looking for strings.h - found
Looking for arpa/inet.h
Looking for arpa/inet.h - not found
Looking for winsock2.h
Looking for winsock2.h - found
Looking for mem.h
Looking for mem.h - found
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for BaseTsd.h
Looking for BaseTsd.h - found
Check if the system is big endian
Searching 16 bit integer
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for stddef.h
Looking for stddef.h - found
Check size of unsigned short
Check size of unsigned short - done
Using unsigned short
Check if the system is big endian - little endian
Using gcc specific compiler options
CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):
  Could NOT find ZLIB (missing: ZLIB_LIBRARY)
Call Stack (most recent call first):
  C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:288 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindZLIB.cmake:47 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:309 (FIND_PACKAGE)

I think I'm going to have a heart-attack. The ZLIB part appears to have worked. I haven't yet input the other dependencies so this this time I have other errors related to other dependencies, not ZLIB.

Fingers crossed.. I may get there yet.. In a couple of years thing should be up and running.

Thanks for that last top Bob it may very well have been the key..

Keep us posted on your progress. I've downloaded/installed the toolchain to build Podofo in order to recreate your issues. So, hopefully, I may be of some additional help.

OK.. Something else.. Please read this carefully as it will be easy to misinterpret what I am saying.

The CMAKE Gui requires you to enter a couple of variables when building the PODOFO Library. One is for the Include Directory of ZLIB and the other is for the Library Directory for ZLIB.

In the CMAKELists file which came with PODOFO the two references to variables (and in no way does it tell you to set these even though I can see why you would) as:

ZLIB_INCLUDE_DIR
ZLIB_LIBRARIES

If you enter the ZLIB_INCLUDE_DIR variable into CMAKE and direct the Path of this diretory to the ZLIB directory then all is fine. CMAKE finds it without a worry.

If you enter the ZLIB_LIBRARIES variable in CMAKE and direct the Path of this directory to where your built ZLIB files are then you will get an error. The error specifically states that CMAKE cannot fine the ZLIB_LIBRARY . Notice I've bolded the 'S' in LIBRARIES and the 'Y' in LIBRARY. So you would think from this that you can correct this problem by changing the ZLIB_LIBRARIES variable to ZLIB_LIBRARY. But this doesn't work either. I also tried creating a Debug folder and setting the path to that folder under the ZLIB_LIBRARY variable and it just won't work.

The only way it will work is this. It doesn't matter where the built ZLIB Library files are (I know some may argue with this) as long as you set the CMAKE variable in the CMAKE gui to ZLIB_LIBRARY_DEBUG or ZLIB_LIBRARY_RELEASE or both. As stated in one of the posts above if the Zlib Release Library cannot be found then it defaults to using the Debug Library for both.

My question is this. If this software (PODOFO) is distributed to be build via CMAKE and the CMAKELists file doesn't explain that you need to specify a Debug and Release Library variable such as ZLIB_LIBRARY_DEBUG & ZLIB_LIBRARY_RELEASE (thats if you have release version) then how in the world would you know which variable CMAKE will be able to recognise as the Library directory. Surely they don't expect you to go through the assortment of CMAKE files in the PODOFO/CMAKE directory to work this out. There must be a simpler way of knowing this? Is it common knowledge that ZLIB_LIBRARIES actually means ZLIB_LIBRARY_DEBUG & ZLIB_LIBRARY_RELEASE or do you have to waite to get the error before you find this out?

I'll be interested to hear what people have to say about this as I'm not sure how this can be worked out otherwise.

Oh well, since I'm on a roll I'll add something else.
In the PODOFO Cmake directory there is a LibraryDebugandRelease file which uses the below criteria for finding library directories. It explains why just ZLIB_LIBRARY won't work which answers my own question above.

I'm just not sure why I have to assume that there is a debug or release version. Is it always the case that there is either a debug or release library or both??

MACRO(SET_LIBRARY_FROM_DEBUG_AND_RELEASE _NAME)

**  IF(NOT DEFINED "${_NAME}_LIBRARY_RELEASE" OR NOT DEFINED "${_NAME}_LIBRARY_DEBUG")
    MESSAGE(FATAL_ERROR "${_NAME}_LIBRARY_DEBUG OR ${_NAME}_LIBRARY_RELEASE undefined")**
  ENDIF(NOT DEFINED "${_NAME}_LIBRARY_RELEASE" OR NOT DEFINED "${_NAME}_LIBRARY_DEBUG")
  IF(${_NAME}_LIBRARY_RELEASE AND ${_NAME}_LIBRARY_DEBUG)
    SET(${_NAME}_LIBRARY "optimized;${${_NAME}_LIBRARY_RELEASE};debug;${${_NAME}_LIBRARY_DEBUG}")
  ELSE(${_NAME}_LIBRARY_RELEASE AND ${_NAME}_LIBRARY_DEBUG)
    IF(${_NAME}_LIBRARY_DEBUG)
      MESSAGE("WARNING: ${_NAME} debug library will be used even for release builds")
      SET(${_NAME}_LIBRARY ${${_NAME}_LIBRARY_DEBUG})
    ELSE(${_NAME}_LIBRARY_DEBUG)
      SET(${_NAME}_LIBRARY ${${_NAME}_LIBRARY_RELEASE})
    ENDIF(${_NAME}_LIBRARY_DEBUG)
  ENDIF(${_NAME}_LIBRARY_RELEASE AND ${_NAME}_LIBRARY_DEBUG)

ENDMACRO(SET_LIBRARY_FROM_DEBUG_AND_RELEASE

Is it common knowledge that ZLIB_LIBRARIES actually means ZLIB_LIBRARY_DEBUG & ZLIB_LIBRARY_RELEASE or do you have to waite to get the error before you find this out?

 - Find zlib
 Find the native ZLIB includes and library

  ZLIB_INCLUDE_DIR - where to find zlib.h, etc.
  ZLIB_LIBRARIES   - List of libraries when using zlib.
  ZLIB_FOUND       - True if zlib found.

The above info can be found in the FindZlib.cmake file. Possibly reviewing this file may shed more light on your question.

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.