Howto build Gtk2 binary ppm packages for Windows.

Requirements

Steps

Step 1.

Install Visual C++ 6 or the .Net Framework SDK and Platform SDK. Make sure that the binaries (bin) are available in the system path and the libraries (lib) and includes (include) are programmed as SET variables. Here is an example of how to setup a minimal Visual C++ installation (from http://wiki.tcl.tk/11970).

The standard installation of Microsoft Visual Studio is some 400MB. I recently needed to do some debugging on a machine that I didn't want to install VC6 on (because it can be hard to properly uninstall). However, if all you need is VC6 to compile stuff, then you don't need all the other stuff. Here is how. Note that my target was building tcl - if you are building something else you may need to copy a few more bits.

Create the following directory tree.

 vc6
 |-bin
 |-include
 |-lib

Copy the whole of lib and include directories from your VC98\ to your new tree. Then copy from the VC98\bin directory to your bin directory cl.exe, c1.dll, c1xx.dll, c2.dll, cvtres.exe, lib.exe, link.exe and nmake.exe Then copy from MSDev98\bin to your bin mspdb60.dll, rc.exe and rcdll.dll.

Setup a vc6setup.bat file with the following to create a build environment

 echo Setting environment for minimal Visual C++ 6
 set MSVCDir=drive:\path\to\vc6
 set INCLUDE=%MSVCDir%\include
 set LIB=%MSVCDir%\lib
 set PATH=%MSVCDir%\bin;%PATH%
 Title Minimal VC6 build shell

** Note. This will only alter the path and environment variables for that shell session. You have to place these items into the permanent path and environment if you want them to persist across command sessions.

The installation takes about 70MB disk space so can easily be put on a USB memory stick if needed.

Once you have finished on the target system a simple rmdir /q /s vc6 will get rid of the whole lot.

I use this setup for building my binary packages, but setting something similar for the .Net Framework SDK and Platform SDK will also work.

Step 2.

You need to install ExtUtils::Depends and ExtUtils::PkgConfig. A suitable version of ExtUtils::Depends is available via ActiveState PPM, but ExtUtils::PkgConfig is not available. You will have to compile it from source. Download it from the Gtk2 Sourceforge downloads page (http://sourceforge.net/projects/gtk2-perl).

** Note. You need to patch ExtUtils::Depends and ExtUtils::PkgConfig when compiling from source before they will install on Windows. Open up "Makefile.pl" for each package, find the line

sub postamble { 

and place the following code at the beginning of the subroutine:

return @_ if $^O eq 'MSWin32';

The authors have been notified of this and will implement a patch in later versions.

This is fixed as of ExtUtils::Dependsg 0.205 and ExtUtils::PkgConfig 1.07. -- muppet

Step 3.

Get the Glib and Gtk+ runtime and developer files from http://www.gimp.org/~tml/gimp/win32/downloads.html. Here are the files you need:

atk-*.zip
atk-dev-*.zip
freetype-*-bin.zip
freetype-*-lib.zip
gettext-runtime-*.woe32.zip
gettext-tools-*.bin.woe32.with-msvcrt.zip
glib-*.zip
glib-dev-*.zip
gtk+-*.zip
gtk+-dev-*.zip
jpeg-*-bin.zip
jpeg-*-lib.zip
libiconv-*.bin.woe32.zip
libpng-*-bin.zip
libpng-*-lib.zip
libpng-*-bin.zip
libpng-*-lib.zip
pango-*.zip
pango-dev-*.zip
pkgconfig-*.zip
tiff-*-bin.zip
tiff-*-lib.zip
zlib-*-bin.zip
zlib-*-lib.zip

The * stands for the version number. Get whatever the latest version is. Unzip all of the files into c:\usr (or some other location). It is not necessary to separate the runtime files from the development files. Add the following to your system path: "c:\usr\bin;c:\usr\lib;"

Step 4.

Compile and install Glib perl. Download the Glib source from the Gtk2 Sourceforge downloads page (http://sourceforge.net/projects/gtk2-perl). Unpack the tar.gz into a directory, open cmd.exe and change to the directory where you unpacked the source code. Type the following:

> perl Makefile.pl
> nmake test

You may get a stop error about "command too long". If this is the case, look at the perl command that was called in Makefile, find the line and remove all spaces from the command. Save the file and rerun nmake. This is due to string length limitations in Microsoft shells. Removing the spaces from the command should bring you under the limit of 2047 characters.

Once the files have compiled and tests have pass ok, create a ppd distribution and install your brand new shiny Glib perl via PPM. See Appendix A for notes on creating a .ppd file.

Step 5.

Compile and install Gtk2 perl. Download the Gtk2 source from the Gtk2 Sourceforge download page (http://sourceforge.net/projects/gtk2-perl). There is a bug in Glib::MakeHelper that prevents "perl Makefile.pl" from properly detecting xs and map files.

This bug is fixed as of Glib 1.073 and will be in the stable 1.080 release. -- muppet

Change into the directory where you unpacked your Gtk2 source. Type the following:

> perl Makefile.pl
> nmake

If there are any failures in nmake (unexported symbols), you will either need to comment them out in the source or contact the mailing list for assistance. Once nmake has successfully compiled your binaries you can optionally run

> nmake test

but it takes a long time and tells you about all kinds of failures that really are only significant to the developers. So, just skip that part. (In general, however, test suites are a good thing, and help assure you that the software you just built is okay. If you can debug and fix any of the failures, which are mostly due to different behavior of gtk+ on win32 than on x11, please let us know and we'll fix it upstream. -- muppet)

Package Gtk2 into a .ppd and install it via PPM. (See Appendix A).

Now change into the gtk-demo directory and run: perl main.pl. Test out your new build to see if it works!

Appendix A - Howto build a PPM installable .ppd

Credit to a post on perlmonks for this: http://perlmonks.thepen.com/113448.html

In your build directory, tar.gz the "blib" directory. Then run "nmake ppd" to create a ppd file.

c:\> tar cvf package.tar blib
c:\> gzip --best package.tar
c:\> nmake ppd

Open the resulting *.ppd file and add the name of the tar.gz file you created between the double quotes of the portion that reads:

<CODEBASE HREF="" />

Save the file. To install:

c:\> ppm install *.ppd

Works like a charm. The really nice thing about this method is you can also uninstall packages if you find you don't like them (or you break something).

c:\> ppm remove *.ppd