Author Topic: Compiling libpng and zlib  (Read 5573 times)

jayvl

  • Guest
Compiling libpng and zlib
« on: March 15, 2015, 06:42:34 pm »
Using codeblocks 13.12 on windows 7 with mingw compiler.
Trying to compile the libpng library and its zlib dependency. Have both folders (libpng1616\ and zlib-1.2.8\ ) under "C:\...\mylibs\".

Imported the vstudio .sln file after specifying the relative path of zlib in the file "lpng1616\projects\vstudio\zlib.props". Importing spawns several codeblocks project files under the folders in "libpng1616\projects\vstudio\". 7 Projects but I'm only interested in compiling first zlib and then libpng (which should link to zlib).

The problem is when compiling (zlib project) the zlib source locations are not found. This is also indicated by broken .c file icons under the sources folder. It seems codeblocks literally copies the string $ZLibSrcDir as a path. Nowhere in the settings can I find where this variable is specified (it should be ..\..\..\..\zlib-1.2.8 since the project is in "lpng1616\projects\vstudio\zlib\zlib.cbp")

After manually:
- removing the non-existing source dir
- adding the eleven .c files
- specifying that it is a static library in build options
the zlib project compiles into "libzlib.a" without errors.

Going on to compile libpng project I had to change the linked library (it referred to libz.lib in the non-existing directory) to my new libzlib.a file. Then set the compiler search directory to the proper zlib folder. Added the pnglinconf.h file to "mylibs\pnglib1616\" and voila i got a working libpng.a file.

Tested succesful with the pngtest project, which also required first tweaking build options and copying a png file to the project directory.

I dont understand why every project has 4 build targets instead of 2 (debug/release), each has a library win32 and a win32 version. I also dont get  why they don't offer precompiled files for windows to download.
But my question is: is there an easier way to make these libraries (with CB, not MSYS or cygwin or MSVS). And if not is there a tool that helps better convert the .sln to .cbp projects?


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Compiling libpng and zlib
« Reply #1 on: March 19, 2015, 03:52:50 pm »
If you can find a place that supplies premake or CMake build files that might work better.

It could also be more work and do a worse job.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org