| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 | 
    Installing libpngContents       I. Simple installation      II. Rebuilding the configure scripts     III. Using scripts/makefile*      IV. Using cmake       V. Directory structure      VI. Building with project files     VII. Building with makefiles    VIII. Configuring libpng for 16-bit platforms      IX. Configuring for DOS       X. Configuring for Medium Model      XI. Prepending a prefix to exported symbols     XII. Configuring for compiler xxx:    XIII. Removing unwanted object code     XIV. Enabling or disabling hardware optimizations      XV. Changes to the build and configuration of libpng in libpng-1.5.x     XVI. Setjmp/longjmp issues    XVII. Common linking failures   XVIII. Other sources of information about libpngI. Simple installationOn Unix/Linux and similar systems, you can simply type    ./configure [--prefix=/path]    make check    make installand ignore the rest of this document.  "/path" is the path to the directorywhere you want to install the libpng "lib", "include", and "bin"subdirectories.If you downloaded a GIT clone, you will need to run ./autogen.sh beforerunning ./configure, to create "configure" and "Makefile.in" which arenot included in the GIT repository.Note that "configure" is only included in the "*.tar" distributions and notin the "*.zip" or "*.7z" distributions. If you downloaded one of thosedistributions, see "Building with project files" or "Building with makefiles",below.II. Rebuilding the configure scriptsIf configure does not work on your system, or if you have a need tochange configure.ac or Makefile.am, and you have a reasonablyup-to-date set of tools, running ./autogen.sh in a git clone beforerunning ./configure may fix the problem.  To be really sure that youaren't using any of the included pre-built scripts, especially if youare building from a tar distribution instead of a git distribution,do this:    ./configure --enable-maintainer-mode    make maintainer-clean    ./autogen.sh --maintainer --clean    ./autogen.sh --maintainer    ./configure [--prefix=/path] [other options]    make    make install    make checkIII. Using scripts/makefile*Instead, you can use one of the custom-built makefiles in the"scripts" directory    cp scripts/pnglibconf.h.prebuilt pnglibconf.h    cp scripts/makefile.system makefile    make test    make installThe files that are presently available in the scripts directoryare listed and described in scripts/README.txt.Or you can use one of the "projects" in the "projects" directory.Before installing libpng, you must first install zlib, if itis not already on your system.  zlib can usually be foundwherever you got libpng; otherwise go to https://zlib.net/.  You canplace zlib in the same directory as libpng or in another directory.If your system already has a preinstalled zlib you will still needto have access to the zlib.h and zconf.h include files thatcorrespond to the version of zlib that's installed.If you wish to test with a particular zlib that is not first in thestandard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,and LD_LIBRARY_PATH in your environment before running "make test"or "make distcheck":    ZLIBLIB=/path/to/lib export ZLIBLIB    ZLIBINC=/path/to/include export ZLIBINC    CPPFLAGS="-I$ZLIBINC" export CPPFLAGS    LDFLAGS="-L$ZLIBLIB" export LDFLAGS    LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATHIf you are using one of the makefile scripts, put ZLIBLIB and ZLIBINCin your environment and type    make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC testIV. Using cmakeIf you want to use "cmake" (see www.cmake.org), type    cmake . -DCMAKE_INSTALL_PREFIX=/path    make    make installAs when using the simple configure method described above, "/path" points tothe installation directory where you want to put the libpng "lib", "include",and "bin" subdirectories.V. Directory structureYou can rename the directories that you downloaded (theymight be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"or "zlib128") 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  => libpng source files          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             arm-neon, conftest, examples, gregbook, libtests, pngminim,             pngminus, pngsuite, tools, visupng          projects             cbuilder5, owatcom, visualc71, vstudio, xcode          scripts             makefile.*             *.def (module definition files)             etc.          pngtest.png          etc.      zlib          README, *.h, *.c contrib, etc.If the line endings in the files look funny, you may wish to get the otherdistribution of libpng.  It is available in both tar.gz (UNIX style lineendings) and zip (DOS style line endings) formats.VI. Building with project filesIf you are building libpng with MSVC, you can enter thelibpng projects\visualc71 or vstudio directory and follow the instructionsin README.txt.Otherwise enter the zlib directory and follow the instructions in zlib/README,then come back here and run "configure" or choose the appropriatemakefile.sys in the scripts directory.VII. Building with makefilesCopy the file (or files) that you need from thescripts directory into this directory, for exampleMSDOS example:    copy scripts\makefile.msc makefile    copy scripts\pnglibconf.h.prebuilt pnglibconf.hUNIX example:    cp scripts/makefile.std makefile    cp scripts/pnglibconf.h.prebuilt pnglibconf.hRead the makefile to see if you need to change any source ortarget directories to match your preferences.Then read pnglibconf.dfa to see if you want to make any configurationchanges.Then just run "make" which will create the libpng library inthis directory and "make test" which will run a quick test that readsthe "pngtest.png" file and writes a "pngout.png" file that should beidentical to it.  Look for "9782 zero samples" in the output of thetest.  For more confidence, you can run another test by typing"pngtest pngnow.png" and looking for "289 zero samples" in the output.Also, you can run "pngtest -m contrib/pngsuite/*.png" and compareyour output with the result shown in contrib/pngsuite/README.Most of the makefiles will allow you to run "make install" toput the library in its final resting place (if you want todo that, run "make install" in the zlib directory first if necessary).Some also allow you to run "make test-installed" after you haverun "make install".VIII. Configuring libpng for 16-bit platformsYou will want to look into zconf.h to tell zlib (and thus libpng) thatit cannot allocate more than 64K at a time.  Even if you can, the memorywon't be accessible.  So limit zlib and libpng to 64K by defining MAXSEG_64K.IX. Configuring for DOSFor DOS users who only have access to the lower 640K, you willhave to limit zlib's memory usage via a png_set_compression_mem_level()call.  See zlib.h or zconf.h in the zlib library for more information.X. Configuring for Medium ModelLibpng's support for medium model has been tested on most of the popularcompilers.  Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD getsdefined, and FAR gets defined to far in pngconf.h, and you should beall set.  Everything in the library (except for zlib's structure) isexpecting far data.  You must use the typedefs with the p or pp onthe end for pointers (or at least look at them and be careful).  Makenote that the rows of data are defined as png_bytepp, which isan "unsigned char far * far *".XI. Prepending a prefix to exported symbolsStarting with libpng-1.6.0, you can configure libpng (when using the"configure" script) to prefix all exported symbols by means of theconfiguration option "--with-libpng-prefix=FOO_", where FOO_ can be anystring beginning with a letter and containing only uppercaseand lowercase letters, digits, and the underscore (i.e., a C languageidentifier).  This creates a set of macros in pnglibconf.h, so this istransparent to applications; their function calls get transformed bythe macros to use the modified names.XII. Configuring for compiler xxx:All includes for libpng are in pngconf.h.  If you need to add, changeor delete an include, this is the place to do it.The includes that are not needed outside libpng are placed in pngpriv.h,which is only used by the routines inside libpng itself.The files in libpng proper only include pngpriv.h and png.h, whichin turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.As of libpng-1.5.0, pngpriv.h also includes three other private headerfiles, pngstruct.h, pnginfo.h, and pngdebug.h, which contain materialthat previously appeared in the public headers.XIII. Removing unwanted object codeThere are a bunch of #define's in pngconf.h that control what parts oflibpng are compiled.  All the defines end in _SUPPORTED.  If you arenever going to use a capability, you can change the #define to #undefbefore recompiling libpng and save yourself code and data space, oryou can turn off individual capabilities with defines that begin with"PNG_NO_".In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.You can also turn all of the transforms and ancillary chunk capabilitiesoff en masse with compiler directives that definePNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,or all four, along with directives to turn on any of the capabilities thatyou do want.  The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable theextra transformations but still leave the library fully capable of readingand writing PNG files with all known public chunks. Use of thePNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a librarythat is incapable of reading or writing ancillary chunks.  If you arenot using the progressive reading capability, you can turn that offwith PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACINGcapability, which you'll still have).All the reading and writing specific code are in separate files, so thelinker should only grab the files it needs.  However, if you want tomake sure, or if you are building a stand alone library, all thereading files start with "pngr" and all the writing files start with "pngw".The files that don't match either (like png.c, pngtrans.c, etc.)are used for both reading and writing, and always need to be included.The progressive reader is in pngpread.cIf you are creating or distributing a dynamically linked library (a .soor DLL file), you should not remove or disable any parts of the library,as this will cause applications linked with different versions of thelibrary to fail if they call functions not available in your library.The size of the library itself should not be an issue, because onlythose sections that are actually used will be loaded into memory.XIV. Enabling or disabling hardware optimizationsCertain hardware capabilities, such as the Intel SSE instructions,are normally detected at run time. Enable them with configure optionssuch as one of   --enable-arm-neon=yes   --enable-mips-msa=yes   --enable-intel-sse=yes   --enable-powerpc-vsx=yesor enable them all at once with   --enable-hardware-optimizations=yesor, if you are not using "configure", you can use oneor more of   CPPFLAGS += "-DPNG_ARM_NEON"   CPPFLAGS += "-DPNG_MIPS_MSA"   CPPFLAGS += "-DPNG_INTEL_SSE"   CPPFLAGS += "-DPNG_POWERPC_VSX"See for example scripts/makefile.linux-optIf you wish to avoid using them,you can disable them via the configure option   --disable-hardware-optimizationsto disable them all, or   --enable-intel-sse=noto disable a particular one,or via compiler-command options such as   CPPFLAGS += "-DPNG_ARM_NEON_OPT=0, -DPNG_MIPS_MSA_OPT=0,   -DPNG_INTEL_SSE_OPT=0, -DPNG_POWERPC_VSX_OPT=0"If you are using cmake, hardware optimizations are "on"by default. To disable them, use    cmake . -DPNG_ARM_NEON=no -DPNG_INTEL_SSE=no \            -DPNG_MIPS_MSA=no -DPNG_POWERPC_VSX=noor disable them all at once with    cmake . -DPNG_HARDWARE_OPTIMIZATIONS=noXV. Changes to the build and configuration of libpng in libpng-1.5.xDetails of internal changes to the library code can be found in the CHANGESfile and in the GIT repository logs.  These will be of no concern to the vastmajority of library users or builders; however, the few who configure libpngto a non-default feature set may need to change how this is done.There should be no need for library builders to alter build scripts ifthese use the distributed build support - configure or the makefiles -however, users of the makefiles may care to update their build scriptsto build pnglibconf.h where the corresponding makefile does not do so.Building libpng with a non-default configuration has changed completely.The old method using pngusr.h should still work correctly even though theway pngusr.h is used in the build has been changed; however, librarybuilders will probably want to examine the changes to take advantage ofnew capabilities and to simplify their build system.A. Specific changes to library configuration capabilitiesThe exact mechanism used to control attributes of API functions haschanged.  A single set of operating system independent macro definitionsis used and operating system specific directives are defined inpnglibconf.hAs part of this the mechanism used to choose procedure call standards onthose systems that allow a choice has been changed.  At present this onlyaffects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systemsrunning on Intel processors.  As before, PNGAPI is defined where requiredto control the exported API functions; however, two new macros, PNGCBAPIand PNGCAPI, are used instead for callback functions (PNGCBAPI) and(PNGCAPI) for functions that must match a C library prototype (currentlyonly png_longjmp_ptr, which must match the C longjmp function.)  The newapproach is documented in pngconf.hDespite these changes, libpng 1.5.0 only supports the native C functioncalling standard on those platforms tested so far ("__cdecl" on MicrosoftWindows).  This is because the support requirements for alternativecalling conventions seem to no longer exist.  Developers who find itnecessary to set PNG_API_RULE to 1 should advise the mailing list(png-mng-implement) of this and library builders who use Openwatcom andtherefore set PNG_API_RULE to 2 should also contact the mailing list.B. Changes to the configuration mechanismPrior to libpng-1.5.0 library builders who needed to configure libpnghad either to modify the exported pngconf.h header file to add systemspecific configuration or had to write feature selection macros intopngusr.h and cause this to be included into pngconf.h by definingPNG_USER_CONFIG. The latter mechanism had the disadvantage that anapplication built without PNG_USER_CONFIG defined would see theunmodified, default, libpng API and thus would probably fail to link.These mechanisms still work in the configure build and in any makefilebuild that builds pnglibconf.h, although the feature selection macroshave changed somewhat as described above.  In 1.5.0, however, pngusr.h isprocessed only once, at the time the exported header file pnglibconf.h isbuilt.  pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignoredafter the build of pnglibconf.h and it is never included in an applicationbuild.The formerly used alternative of adding a list of feature macros to theCPPFLAGS setting in the build also still works; however, the macros will becopied to pnglibconf.h and this may produce macro redefinition warningswhen the individual C files are compiled.All configuration now only works if pnglibconf.h is built fromscripts/pnglibconf.dfa.  This requires the program awk.  Brian Kernighan(the original author of awk) maintains C source code of that awk and thisand all known later implementations (often called by subtly differentnames - nawk and gawk for example) are adequate to build pnglibconf.h.The Sun Microsystems (now Oracle) program 'awk' is an earlier versionand does not work; this may also apply to other systems that have afunctioning awk called 'nawk'.Configuration options are now documented in scripts/pnglibconf.dfa.  Thisfile also includes dependency information that ensures a configuration isconsistent; that is, if a feature is switched off, dependent features arealso switched off.  As a recommended alternative to using feature macros inpngusr.h a system builder may also define equivalent options in pngusr.dfa(or, indeed, any file) and add that to the configuration by settingDFA_XTRA to the file name.  The makefiles in contrib/pngminim illustratehow to do this, and also illustrate a case where pngusr.h is still required.After you have built libpng, the definitions that were recorded inpnglibconf.h are available to your application (pnglibconf.h is includedin png.h and gets installed alongside png.h and pngconf.h in your$PREFIX/include directory).  Do not edit pnglibconf.h after you have builtlibpng, because than the settings would not accurately reflect the settingsthat were used to build libpng.XVI. Setjmp/longjmp issuesLibpng uses setjmp()/longjmp() for error handling.  Unfortunately setjmp()is known to be not thread-safe on some platforms and we don't know ofany platform where it is guaranteed to be thread-safe.  Therefore, ifyour application is going to be using multiple threads, you shouldconfigure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with-DPNG_NO_SETJMP on your compile line, or with    #undef PNG_SETJMP_SUPPORTEDin your pnglibconf.h or pngusr.h.Starting with libpng-1.6.0, the library included a "simplified API".This requires setjmp/longjmp, so you must either build the librarywith PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTEDand PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.XVII. Common linking failuresIf your application fails to find libpng or zlib entries while linking:  Be sure "-lz" appears after "-lpng" on your linking command.  Be sure you have built libpng, zlib, and your application for the  same platform (e.g., 32-bit or 64-bit).  If you are using the vstudio project, observe the WARNING in  project/vstudio/README.txt.XVIII. Other sources of information about libpng:Further information can be found in the README and libpng-manual.txtfiles, in the individual makefiles, in png.h, and the manual pageslibpng.3 and png.5.Copyright (c) 1998-2002,2006-2016 Glenn Randers-PehrsonThis document is released under the libpng license.For conditions of distribution and use, see the disclaimerand license in png.h.
 |