INSTALL 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. Installing libpng
  2. Contents
  3. I. Simple installation
  4. II. Rebuilding the configure scripts
  5. III. Using scripts/makefile*
  6. IV. Using cmake
  7. V. Directory structure
  8. VI. Building with project files
  9. VII. Building with makefiles
  10. VIII. Configuring libpng for 16-bit platforms
  11. IX. Configuring for DOS
  12. X. Configuring for Medium Model
  13. XI. Prepending a prefix to exported symbols
  14. XII. Configuring for compiler xxx:
  15. XIII. Removing unwanted object code
  16. XIV. Changes to the build and configuration of libpng in libpng-1.5.x
  17. XV. Setjmp/longjmp issues
  18. XVI. Other sources of information about libpng
  19. I. Simple installation
  20. On Unix/Linux and similar systems, you can simply type
  21. ./configure [--prefix=/path]
  22. make check
  23. make install
  24. and ignore the rest of this document. "/path" is the path to the directory
  25. where you want to install the libpng "lib", "include", and "bin"
  26. subdirectories.
  27. If you downloaded a GIT clone, you will need to run ./autogen.sh before
  28. running ./configure, to create "configure" and "Makefile.in" which are
  29. not included in the GIT repository.
  30. Note that "configure" is only included in the "*.tar" distributions and not
  31. in the "*.zip" or "*.7z" distributions. If you downloaded one of those
  32. distributions, see "Building with project files" or "Building with makefiles",
  33. below.
  34. II. Rebuilding the configure scripts
  35. If configure does not work on your system, or if you have a need to
  36. change configure.ac or Makefile.am, and you have a reasonably
  37. up-to-date set of tools, running ./autogen.sh in a git clone before
  38. running ./configure may fix the problem. To be really sure that you
  39. aren't using any of the included pre-built scripts, you can do this:
  40. ./configure --enable-maintainer-mode
  41. make maintainer-clean
  42. ./autogen.sh --maintainer --clean
  43. ./autogen.sh --maintainer
  44. ./configure [--prefix=/path] [other options]
  45. make
  46. make install
  47. make check
  48. III. Using scripts/makefile*
  49. Instead, you can use one of the custom-built makefiles in the
  50. "scripts" directory
  51. cp scripts/pnglibconf.h.prebuilt pnglibconf.h
  52. cp scripts/makefile.system makefile
  53. make test
  54. make install
  55. The files that are presently available in the scripts directory
  56. are listed and described in scripts/README.txt.
  57. Or you can use one of the "projects" in the "projects" directory.
  58. Before installing libpng, you must first install zlib, if it
  59. is not already on your system. zlib can usually be found
  60. wherever you got libpng; otherwise go to http://zlib.net. You can place
  61. zlib in in the same directory as libpng or in another directory.
  62. If your system already has a preinstalled zlib you will still need
  63. to have access to the zlib.h and zconf.h include files that
  64. correspond to the version of zlib that's installed.
  65. If you wish to test with a particular zlib that is not first in the
  66. standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
  67. and LD_LIBRARY_PATH in your environment before running "make test"
  68. or "make distcheck":
  69. ZLIBLIB=/path/to/lib export ZLIBLIB
  70. ZLIBINC=/path/to/include export ZLIBINC
  71. CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
  72. LDFLAGS="-L$ZLIBLIB" export LDFLAGS
  73. LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
  74. If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
  75. in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
  76. IV. Using cmake
  77. If you want to use "cmake" (see www.cmake.org), type
  78. cmake . -DCMAKE_INSTALL_PREFIX=/path
  79. make
  80. make install
  81. As when using the simple configure method described above, "/path" points to
  82. the installation directory where you want to put the libpng "lib", "include",
  83. and "bin" subdirectories.
  84. V. Directory structure
  85. You can rename the directories that you downloaded (they
  86. might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
  87. or "zlib128") so that you have directories called "zlib" and "libpng".
  88. Your directory structure should look like this:
  89. .. (the parent directory)
  90. libpng (this directory)
  91. INSTALL (this file)
  92. README
  93. *.h, *.c => libpng source files
  94. CMakeLists.txt => "cmake" script
  95. configuration files:
  96. configure.ac, configure, Makefile.am, Makefile.in,
  97. autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
  98. libpng-config.in, aclocal.m4, config.h.in, config.sub,
  99. depcomp, install-sh, mkinstalldirs, test-pngtest.sh
  100. contrib
  101. arm-neon, conftest, examples, gregbook, libtests, pngminim,
  102. pngminus, pngsuite, tools, visupng
  103. projects
  104. cbuilder5, owatcom, visualc71, vstudio, xcode
  105. scripts
  106. makefile.*
  107. *.def (module definition files)
  108. etc.
  109. pngtest.png
  110. etc.
  111. zlib
  112. README, *.h, *.c contrib, etc.
  113. If the line endings in the files look funny, you may wish to get the other
  114. distribution of libpng. It is available in both tar.gz (UNIX style line
  115. endings) and zip (DOS style line endings) formats.
  116. VI. Building with project files
  117. If you are building libpng with MSVC, you can enter the
  118. libpng projects\visualc71 or vstudio directory and follow the instructions
  119. in README.txt.
  120. Otherwise enter the zlib directory and follow the instructions in zlib/README,
  121. then come back here and run "configure" or choose the appropriate
  122. makefile.sys in the scripts directory.
  123. VII. Building with makefiles
  124. Copy the file (or files) that you need from the
  125. scripts directory into this directory, for example
  126. MSDOS example: copy scripts\makefile.msc makefile
  127. copy scripts\pnglibconf.h.prebuilt pnglibconf.h
  128. UNIX example: cp scripts/makefile.std makefile
  129. cp scripts/pnglibconf.h.prebuilt pnglibconf.h
  130. Read the makefile to see if you need to change any source or
  131. target directories to match your preferences.
  132. Then read pnglibconf.dfa to see if you want to make any configuration
  133. changes.
  134. Then just run "make" which will create the libpng library in
  135. this directory and "make test" which will run a quick test that reads
  136. the "pngtest.png" file and writes a "pngout.png" file that should be
  137. identical to it. Look for "9782 zero samples" in the output of the
  138. test. For more confidence, you can run another test by typing
  139. "pngtest pngnow.png" and looking for "289 zero samples" in the output.
  140. Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
  141. your output with the result shown in contrib/pngsuite/README.
  142. Most of the makefiles will allow you to run "make install" to
  143. put the library in its final resting place (if you want to
  144. do that, run "make install" in the zlib directory first if necessary).
  145. Some also allow you to run "make test-installed" after you have
  146. run "make install".
  147. VIII. Configuring libpng for 16-bit platforms
  148. You will want to look into zconf.h to tell zlib (and thus libpng) that
  149. it cannot allocate more than 64K at a time. Even if you can, the memory
  150. won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
  151. IX. Configuring for DOS
  152. For DOS users who only have access to the lower 640K, you will
  153. have to limit zlib's memory usage via a png_set_compression_mem_level()
  154. call. See zlib.h or zconf.h in the zlib library for more information.
  155. X. Configuring for Medium Model
  156. Libpng's support for medium model has been tested on most of the popular
  157. compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
  158. defined, and FAR gets defined to far in pngconf.h, and you should be
  159. all set. Everything in the library (except for zlib's structure) is
  160. expecting far data. You must use the typedefs with the p or pp on
  161. the end for pointers (or at least look at them and be careful). Make
  162. note that the rows of data are defined as png_bytepp, which is
  163. an "unsigned char far * far *".
  164. XI. Prepending a prefix to exported symbols
  165. Starting with libpng-1.6.0, you can configure libpng (when using the
  166. "configure" script) to prefix all exported symbols by means of the
  167. configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
  168. string beginning with a letter and containing only uppercase
  169. and lowercase letters, digits, and the underscore (i.e., a C language
  170. identifier). This creates a set of macros in pnglibconf.h, so this is
  171. transparent to applications; their function calls get transformed by
  172. the macros to use the modified names.
  173. XII. Configuring for compiler xxx:
  174. All includes for libpng are in pngconf.h. If you need to add, change
  175. or delete an include, this is the place to do it.
  176. The includes that are not needed outside libpng are placed in pngpriv.h,
  177. which is only used by the routines inside libpng itself.
  178. The files in libpng proper only include pngpriv.h and png.h, which
  179. in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
  180. As of libpng-1.5.0, pngpriv.h also includes three other private header
  181. files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
  182. that previously appeared in the public headers.
  183. XIII. Removing unwanted object code
  184. There are a bunch of #define's in pngconf.h that control what parts of
  185. libpng are compiled. All the defines end in _SUPPORTED. If you are
  186. never going to use a capability, you can change the #define to #undef
  187. before recompiling libpng and save yourself code and data space, or
  188. you can turn off individual capabilities with defines that begin with
  189. PNG_NO_.
  190. In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
  191. You can also turn all of the transforms and ancillary chunk capabilities
  192. off en masse with compiler directives that define
  193. PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
  194. or all four, along with directives to turn on any of the capabilities that
  195. you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
  196. extra transformations but still leave the library fully capable of reading
  197. and writing PNG files with all known public chunks. Use of the
  198. PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
  199. that is incapable of reading or writing ancillary chunks. If you are
  200. not using the progressive reading capability, you can turn that off
  201. with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
  202. capability, which you'll still have).
  203. All the reading and writing specific code are in separate files, so the
  204. linker should only grab the files it needs. However, if you want to
  205. make sure, or if you are building a stand alone library, all the
  206. reading files start with "pngr" and all the writing files start with "pngw".
  207. The files that don't match either (like png.c, pngtrans.c, etc.)
  208. are used for both reading and writing, and always need to be included.
  209. The progressive reader is in pngpread.c
  210. If you are creating or distributing a dynamically linked library (a .so
  211. or DLL file), you should not remove or disable any parts of the library,
  212. as this will cause applications linked with different versions of the
  213. library to fail if they call functions not available in your library.
  214. The size of the library itself should not be an issue, because only
  215. those sections that are actually used will be loaded into memory.
  216. XIV. Changes to the build and configuration of libpng in libpng-1.5.x
  217. Details of internal changes to the library code can be found in the CHANGES
  218. file and in the GIT repository logs. These will be of no concern to the vast
  219. majority of library users or builders; however, the few who configure libpng
  220. to a non-default feature set may need to change how this is done.
  221. There should be no need for library builders to alter build scripts if
  222. these use the distributed build support - configure or the makefiles -
  223. however, users of the makefiles may care to update their build scripts
  224. to build pnglibconf.h where the corresponding makefile does not do so.
  225. Building libpng with a non-default configuration has changed completely.
  226. The old method using pngusr.h should still work correctly even though the
  227. way pngusr.h is used in the build has been changed; however, library
  228. builders will probably want to examine the changes to take advantage of
  229. new capabilities and to simplify their build system.
  230. A. Specific changes to library configuration capabilities
  231. The exact mechanism used to control attributes of API functions has
  232. changed. A single set of operating system independent macro definitions
  233. is used and operating system specific directives are defined in
  234. pnglibconf.h
  235. As part of this the mechanism used to choose procedure call standards on
  236. those systems that allow a choice has been changed. At present this only
  237. affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
  238. running on Intel processors. As before, PNGAPI is defined where required
  239. to control the exported API functions; however, two new macros, PNGCBAPI
  240. and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
  241. (PNGCAPI) for functions that must match a C library prototype (currently
  242. only png_longjmp_ptr, which must match the C longjmp function.) The new
  243. approach is documented in pngconf.h
  244. Despite these changes, libpng 1.5.0 only supports the native C function
  245. calling standard on those platforms tested so far (__cdecl on Microsoft
  246. Windows). This is because the support requirements for alternative
  247. calling conventions seem to no longer exist. Developers who find it
  248. necessary to set PNG_API_RULE to 1 should advise the mailing list
  249. (png-mng-implement) of this and library builders who use Openwatcom and
  250. therefore set PNG_API_RULE to 2 should also contact the mailing list.
  251. B. Changes to the configuration mechanism
  252. Prior to libpng-1.5.0 library builders who needed to configure libpng
  253. had either to modify the exported pngconf.h header file to add system
  254. specific configuration or had to write feature selection macros into
  255. pngusr.h and cause this to be included into pngconf.h by defining
  256. PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
  257. application built without PNG_USER_CONFIG defined would see the
  258. unmodified, default, libpng API and thus would probably fail to link.
  259. These mechanisms still work in the configure build and in any makefile
  260. build that builds pnglibconf.h, although the feature selection macros
  261. have changed somewhat as described above. In 1.5.0, however, pngusr.h is
  262. processed only once, at the time the exported header file pnglibconf.h is
  263. built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
  264. after the build of pnglibconf.h and it is never included in an application
  265. build.
  266. The formerly used alternative of adding a list of feature macros to the
  267. CPPFLAGS setting in the build also still works; however, the macros will be
  268. copied to pnglibconf.h and this may produce macro redefinition warnings
  269. when the individual C files are compiled.
  270. All configuration now only works if pnglibconf.h is built from
  271. scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
  272. (the original author of awk) maintains C source code of that awk and this
  273. and all known later implementations (often called by subtly different
  274. names - nawk and gawk for example) are adequate to build pnglibconf.h.
  275. The Sun Microsystems (now Oracle) program 'awk' is an earlier version
  276. and does not work; this may also apply to other systems that have a
  277. functioning awk called 'nawk'.
  278. Configuration options are now documented in scripts/pnglibconf.dfa. This
  279. file also includes dependency information that ensures a configuration is
  280. consistent; that is, if a feature is switched off, dependent features are
  281. also switched off. As a recommended alternative to using feature macros in
  282. pngusr.h a system builder may also define equivalent options in pngusr.dfa
  283. (or, indeed, any file) and add that to the configuration by setting
  284. DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
  285. how to do this, and also illustrate a case where pngusr.h is still required.
  286. After you have built libpng, the definitions that were recorded in
  287. pnglibconf.h are available to your application (pnglibconf.h is included
  288. in png.h and gets installed alongside png.h and pngconf.h in your
  289. $PREFIX/include directory). Do not edit pnglibconf.h after you have built
  290. libpng, because than the settings would not accurately reflect the settings
  291. that were used to build libpng.
  292. XV. Setjmp/longjmp issues
  293. Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
  294. is known to be not thread-safe on some platforms and we don't know of
  295. any platform where it is guaranteed to be thread-safe. Therefore, if
  296. your application is going to be using multiple threads, you should
  297. configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
  298. -DPNG_NO_SETJMP on your compile line, or with
  299. #undef PNG_SETJMP_SUPPORTED
  300. in your pnglibconf.h or pngusr.h.
  301. Starting with libpng-1.6.0, the library included a "simplified API".
  302. This requires setjmp/longjmp, so you must either build the library
  303. with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
  304. and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
  305. XVI. Other sources of information about libpng:
  306. Further information can be found in the README and libpng-manual.txt
  307. files, in the individual makefiles, in png.h, and the manual pages
  308. libpng.3 and png.5.
  309. Using the ./configure script -- 16 December 2002.
  310. =================================================
  311. The ./configure script should work compatibly with what scripts/makefile.*
  312. did, however there are some options you might need to add to configure
  313. explicitly, which previously was done semi-automatically (if you didn't edit
  314. scripts/makefile.* yourself, that is)
  315. CFLAGS="-Wall -O -funroll-loops \
  316. -malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
  317. --with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
  318. You can alternatively specify --includedir=/usr/include, /usr/local/include,
  319. /usr/include/libpng16, or whatever.
  320. If you find that the configure script is out-of-date or is not supporting
  321. your platform properly, try running autogen.sh to regenerate "configure",
  322. "Makefile.in", and the other configuration files. Then try configure again.