xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 1 | Instructions for building libpng using Microsoft Visual Studio |
| 2 | ============================================================== |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 3 | |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 4 | Copyright (c) 2018 Cosmin Truta |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 5 | Copyright (c) 2010,2013,2015 Glenn Randers-Pehrson |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 6 | |
| 7 | This code is released under the libpng license. |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 8 | For conditions of distribution and use, see the disclaimer and license |
| 9 | in png.h |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 10 | |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 11 | This directory contains a solution for building libpng under Microsoft |
| 12 | Visual Studio 2010. It may also work under later versions of Visual |
| 13 | Studio. You should be familiar with Visual Studio before using this |
| 14 | solution. |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 15 | |
| 16 | Initial preparations |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 17 | -------------------- |
| 18 | You must enter some information in zlib.props before attempting to |
| 19 | build with this 'solution'. Please read and edit zlib.props first. |
| 20 | You will probably not be familiar with the contents of zlib.props - |
| 21 | do not worry, it is mostly harmless. |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 22 | |
| 23 | This is all you need to do to build the 'release' and 'release library' |
| 24 | configurations. |
| 25 | |
| 26 | Debugging |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 27 | --------- |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 28 | The release configurations default to /Ox optimization. Full debugging |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 29 | information is produced (in the .pdb), but if you encounter a problem |
| 30 | the optimization may make it difficult to debug. Simply rebuild with a |
| 31 | lower optimization level (e.g. /Od.) |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 32 | |
| 33 | Linking your application |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 34 | ------------------------ |
| 35 | Normally you should link against the 'release' configuration. This |
| 36 | builds a DLL for libpng with the default runtime options used by Visual |
| 37 | Studio. In particular the runtime library is the "MultiThreaded DLL" |
| 38 | version. If you use Visual Studio defaults to build your application, |
| 39 | you should have no problems. |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 40 | |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 41 | If you don't use the Visual Studio defaults your application must still |
| 42 | be built with the default runtime option (/MD). If, for some reason, |
| 43 | it is not then your application will crash inside libpng16.dll as soon |
| 44 | as libpng tries to read from a file handle you pass in. |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 45 | |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 46 | If you do not want to use the DLL, and prefer static linking instead, |
| 47 | you may choose the 'release library' configuration. This is built with |
| 48 | a non-standard runtime library - the "MultiThreaded" version. When you |
| 49 | build your application, it must be compiled with this option (/MT), |
| 50 | otherwise it will not build (if you are lucky) or it will crash (if you |
| 51 | are not.) See the WARNING file that is distributed with this README. |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 52 | |
| 53 | Stop reading here |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 54 | ----------------- |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 55 | You have enough information to build a working application. |
| 56 | |
| 57 | Debug versions have limited support |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 58 | ----------------------------------- |
| 59 | This solution includes limited support for debug versions of libpng. |
| 60 | You do not need these unless your own solution itself uses debug builds |
| 61 | (it is far more effective to debug on the release builds, there is no |
| 62 | point building a special debug build unless you have heap corruption |
| 63 | problems that you can't track down.) |
Chris Craik | b50c217 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 64 | |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 65 | The debug build of libpng is minimally supported. Support for debug |
| 66 | builds of zlib is also minimal. Please keep this in mind, if you want |
| 67 | to use it. |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 68 | |
| 69 | WARNING |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 70 | ------- |
| 71 | Libpng 1.6.x does not use the default run-time library when building |
| 72 | static library builds of libpng; instead of the shared DLL runtime, it |
| 73 | uses a static runtime. If you need to change this, make sure to change |
| 74 | the setting on all the relevant projects: |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 75 | |
| 76 | libpng |
| 77 | zlib |
| 78 | all the test programs |
| 79 | |
| 80 | The runtime library settings for each build are as follows: |
| 81 | |
| 82 | Release Debug |
| 83 | DLL /MD /MDd |
| 84 | Library /MT /MTd |
| 85 | |
xNombre | d07bb0d | 2020-03-10 20:17:12 +0100 | [diff] [blame] | 86 | Also, be sure to build libpng, zlib, and your project, all for the same |
Alex Naidis | 7a055fd | 2016-10-01 12:23:07 +0200 | [diff] [blame] | 87 | platform (e.g., 32-bit or 64-bit). |