Setting Up PNGWriter for Borland C++ Builder Version 6 on Windows XP

by Dr John Charlery

 

This document is a short HowTo about using PNGwriter with the Borland C++ Builder compiler, and is one way to use PNGwriter under Windows.

 

Please note: This document was written with a specific version of PNGwriter in mind, but you should always try to use the latest version of PNGwriter, available from the PNGwriter Website. You should also attempt to use the latest versions of zlib and libpng.

 

Please note: A few versions lower than 0.4.6 won't compile without modification on this compiler (and MSVC7, and perhaps other Windows compilers), so be sure to have at least version 0.4.6.

 

Please note: This HowTo does was not written for the latest versions of PNGwriter, which optionally use FreeType2 for text support. Until it is updated, check the companion HowTo, "Setting Up PNGWriter for Microsoft Visual C++ .NET on Windows XP", or compile PNGwriter without FreeType support if you don't know how to use FreeType for development work.

 

Setting Up ZLIB and LibPNG

 

1.    Extract the zlib 1.1.4 files into the folder C:\zlib (In the C:\zlib folder, delete the file “zlib.lib and rename the file “zlib_bor.lib to “zlib.lib).

 

2.    Extract the libpng 1.2.5 files into the folder C:\libpng.

 

3.    In the folder C:\zlib, edit the file zconf.h”. Delete or simply comment out lines number 190 and 191 i.e.

# define ZEXPORT __declspec(dllexport) WINAPI

# define ZEXPORTVA __declspec(dllexport) WINAPIV

 

4.    Save the file.

5.    Open a command window and go to the folder C:\zlib”. At the command prompt, run the command: BCC32 –c *.c (without the quotes). This will create the zlib object files. Now go to the folder C:\libpng”. At the command prompt, run the command: BCC32 –c *.c (without the quotes). This will create the libpng object files. Close the command window.

 

6.    Open CBuilder6

 

7.    Select File ==> Open Project

 

8.    Go to the directory “C:\libpng\Projects\Borland” and select the file “zlib+libpng.BPGand click “Open”.

 

9.    From Project (in the menu bar) select Options

 

10. Select the “Directories/Conditional tab.

 

11. Click on the “” next to the data window labeled “Conditional defines”.

 

12. If the following lines: PNG_USE_DLL and Z_PREFIX are not present in the larger upper window, then in the lower data window type: PNG_USE_DLL (without the quotes) and click Add. In the lower data window again, type Z_PREFIX (without the quotes) and again, click “Add”.

 

13. Click “Ok to close the “Options window.

 

14. From Project (in the menu bar) select “Add to Project”. Go to the “C:\libpng folder, select all the object files (exceptpngtest.obj) and click Open”.

 

15. From Project (in the menu bar) select “Add to Project” again. Go to the “C:\zlib” folder, select all the object files there (exceptexample.obj) and click Open”.

 

16. From Project again (in the menu bar), select Build All Projects”. The source codes for zlib and libpng will now compile to create the libraries.

 

You may get a number of warnings, but as long as there is no error detected, it will be okay.

 

NB. If you get the linker error message: Fatal: unable to open file ‘NMFAST.LIB” and/or “Fatal: unable to open file ‘TEE.LIB, simply copy the file(s) from the extraction set and place them into CBuilder6 Lib folder (typically, C:\Program Files\Borland\CBuilder6\lib), then Build All Projectsagain.

 

17. In the folder “C:\libpng\project\borland, the following files would have been created:

libpngstat.lib

libpng.lib

zlibstat.lib

zlib.lib

libpng.dll

zlib.dll

libpng.obj

zlib.obj

 

18. At this stage you may want to copy the files:

libpngstat.lib

libpng.lib

zlibstat.lib

zlib.lib

libpng.obj

zlib.obj

to the LIB folder of CBuilder6 and the files:

libpng.dll

zlib.dll

to the System's folder of Windows. It is also convenient to copy the C:\Zlib\*.h files and C:\libpng\*.h files to the “Include” folder of CBuilder6.

 

 

 

Setting Up PNGWriter

 

1.    Extract the PNGWriter-0.3.7 files to your C:\ drive. (Retain the directory structure of the zipped file).

 

2.    If not opened, then open CBuilder6.

 

3.    Close all open projects in CBuilder6.

 

4.    Select File ==> New ==> Other ==> Library then click “Ok”.

 

5.    Select File ==> Save Project As …

 

6.    Go to the directory “PNGWriter-0.3.7\srcand save the project as pngwriter (without the quotes).

 

7.    Select Project ==> Add to project …

In the opened window, go to the folder “C:\PNGWriter-0.3.7\srcand add the filespngwriter.ccandpngwriter.h”.

 

Select Project ==> Add to project … again.

In the opened window, go to the folder C:\libpng and add all the *.obj files (except the file “pngtest.obj).

 

Select Project ==> Add to projectagain.

In the opened window, go to the folder C:\zlib and add all the *.obj files (except the file “example.obj).

 

8.    Select Project ==> Build pngwriter

 

9.    Select Project ==> Compile Unit

 

10. pngwriter.lib is then created in the folder “PNGWriter-0.3.7\src”. You may find it convenient to copy the file pngwriter.libinto the LIB folder of CBuilder6 and the files pngwriter.cc and pngwriter.h to the Include folder of CBuilder6..

 

YOU ARE NOW READY TO GO.

 

Using PNGwriter

 

1.    Create your project in the normal way in CBuilder6.

 

2.    Then select Project ==> Add to project… and add the file pngwriter.lib from the CBuilder6 folder to your project.

 

3.    If you copied the files “pngwriter.ccandpngwriter.hto the Include folder of CBuilder6, then simply use the statement:

# include <pngwriter.cc>

in your program code. Otherwise, include the path where pngwriter.cc” and pngwriter.h” are to be found.

 

You can now build and compile in the usual way.