Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Compiling Gtk+ stack on windows with strawberry perl

by frazap (Beadle)
on Jun 30, 2016 at 15:02 UTC ( #1166929=perlmeditation: print w/replies, xml ) Need Help??

I'm on Windows 10 with a perl 5.24 install in C:/strawberry

I lost so many hours trying to understand why dmake always failed with undefined reference, that I thougt usefull to give a recipe to others when I finaly found a workaround. Here it goes:

  • download the latest (2.24) bundle for the Gtk+ stack from At the time of this writing (july 2016), the package installed using msys2 crashed on the tests with cairo so I return to the gnome ftp site.
  • unzip it in, say C:\prog, and rename the top folder to gtk+ so that you have a C:\prog\gtk+\lib folder that contains a lot of *.def, *.lib, *.dell, *.dell.a files
  • From the control panel use "System - Advanced system settings - Environment variables" to check or add if missing, the variable PKG_CONFIG_PATH in your user variables. Set it to C:prog\gtk+\lib\pkgconfig;C:\strawberry\c\lib\pkgconfig
  • add C:\prog\gtk+\bin to your PATH environment variable
  • from the cpan shell, download the following perl packages using the get command
    • Cairo
    • Glib
    • Pango
    • Gtk2
    The compilation and installation of these package will have to be done in the above order.
  • Each package is downloaded by cpan in C:\strawberry\cpan\build. To open a command shell in each of these folder, select the folder and while pressing the shift key, show the menu with the mouse right click, and select "open command window here".

    From the cpan shell, the command looks perl_module is another way to open a subshell in the corresponding build/module_folder

  • Edit C:\prog\gtk+\lib\pkgconfig\cairo.pc and replace the line having prefix=/devel/target/whatever with prefix=${pcfiledir}/../..

    Repeat this change for the files:

    gobject-2.0.pc pango.pc gtk+-2.0.pc
  • open a command shell in the Cairo-1.... folder
    • run the commands
      perl INC="-IC:/strawberry/c/include/freetype2 -IC:/prog/gt +k+/include/cairo -IC:/prog/gtk+/include/ -I. -I.\build"
    • Check that there is no "Warning (mostly harmless): No library found for ... ". Changing the prefix line in the pc file of the first library searched by allow perl to find all the external libraries.
    • Run
      dmake dmake test dmake install
  • Open a command shell in the cpan/build/Glib.... folder
    • run
    • perl INC="-IC:\prog\gtk+\include\glib-2.0 -IC:\prog\Gtk+\l +ib\glib-2.0\include -I. -I./build" dmake dmake test dmake install
    • On my pc, dmake test failed (tests in t/a.t all failled) but I installed Glib anyway.
  • Open a command shell in the cpan/build/Pango.... folder
    • run
    • perl INC="-IC:\prog\gtk+\include -IC:/prog/gtk+/include/f +reetype2 -IC:/prog/Gtk+/include/cairo -IC:\prog\Gtk+\include\Pango-1. +0 -IC:\prog\Gtk+\include\glib-2.0 -IC:\prog\Gtk+\lib\glib-2.0\include + -I. -I./build -IC:\strawberry\perl\site\lib\Glib\Install -IC:\strawb +erry\perl\site\lib\Cairo\Install" dmake dmake test dmake install
  • Open a command shell in the cpan/build/Gtk2-.... folder
    • run
    • perl INC="-IC:\strawberry\perl\site\lib\Glib\Install -IC:\ +strawberry\perl\site\lib\Pango\Install -IC:\strawberry\perl\site\lib\ +Cairo\Install -IC:\prog\gtk+\include -IC:\prog\Gtk+\include\glib-2.0 +-IC:\prog\gtk+\include\pango-1.0 -IC:\prog\Gtk+\include\cairo -IC:\pr +og\Gtk+\include\atk-1.0 -IC:\prog\gtk+\include\gdk-pixbuf-2.0 -IC:\pr +og\gtk+\include\gtk-2.0 -IC:\prog\gtk+\include\freetype2 -IC:\prog\Gt +k+\lib\glib-2.0\include -IC:\prog\Gtk+\lib\gtk-2.0\include -I. -I./bu +ild" dmake dmake test dmake install


The command given above for perl Makefile.PL has been used for the gtk+-bundle_2.24.10

A newer version could contains new libraries and this would cause dmake to fail with filex.h not found

In that case, you have to add the path to the missing file with -Ic:/this/is/where/thatmissing/file/is in the INC arg given to Makefile.PL.

Perl modules already installed have this header file in


And external libraries to uninstalled perl modules have their header files somewhere in

C:\prog\gtk+\include C:\prog\Gtk+\include\xxx C:\prog\Gtk+\lib\xxx\include
So rerun
perl Makefile.PL INC="changed to include the new path" dmake

until dmake gives no error.

The version of the Gtk2 perl module tested here were 1.2498 and 1.2499. If you try to compile these with an earlier version for the binaries (2.20 instead of 2.24) you will get undefined reference errors with GLib.

Now if you change the path where your gtk+ libraries have been unzipped (or if you remove C:/prog/gtk+/bin from your PATH environment variable, your perl scripts using Gtk2 will crash.

To gain independance from C:/prog/gtk+/bin, you need to copy some dll from this folder to your perl tree directory. This small script does this (the dll list hold for gtk+-bundle_2.24.10):

use strict; use warnings; use File::Copy; my $from= "C:/prog/gtk+/bin/"; my %fm=('C:/strawberry/perl/site/lib/auto/Glib/' => [qw( libglib-2.0-0.dll intl.dll libgthread-2.0-0.dll libgobject-2.0-0.dll )], 'C:/strawberry/perl/site/lib/auto/Cairo/' => [ qw( libcairo-2.dll libexpat-1.dll freetype6.dll libpng14-14.dll libfontconfig-1.dll zlib1.dll )], 'C:/strawberry/perl/site/lib/auto/Pango/' => [qw( libgmodule-2.0-0.dll libpango-1.0-0.dll libpangocairo-1.0-0.dll libpangoft2-1.0-0.dll libpangowin32-1.0-0.dll )], 'C:/strawberry/perl/site/lib/auto/Gtk2/' => [ qw( libgtk-win32-2.0-0.dll libgio-2.0-0.dll libgdk_pixbuf-2.0-0.dll libatk-1.0-0.dll libgdk-win32-2.0-0.dll )]); foreach my $dest (keys %fm){ my $files = $fm{$dest}; foreach my $file (@$files){ print "will copy $from$file to $dest/$file\n"; copy("$from$file", "$dest/$file") or die("failed... : $!"); } }



Replies are listed 'Best First'.
Re: RFC: Compiling Gtk+ stack on windows with strawberry perl
by syphilis (Chancellor) on Jul 02, 2016 at 00:36 UTC
    Looks good !!

    The Gtk+ binaries I currently have won't allow me to build the latest version of Glib (1.321).
    I take it that there's no such problem with the binaries you used ?
    (If so I'll start using them instead of the ones I currently use.)


    At the time of this writing (july 2016), the package installed using msys2 crashed on the tests with cairo

    It might simply be that the msys2 package functions correctly in the msys2 environment, but is incompatible with the native Win32 environment of Strawberry Perl.
    (You might find the msys2 package to be quite satisfactory if you build the Gtk+ modules with msys2's perl.)

Re: RFC: Compiling Gtk+ stack on windows with strawberry perl
by vkon (Curate) on Jun 30, 2016 at 19:14 UTC
    you rock :)

      So far, I've been able to answer my perl questions without even posting thanks to the Monks' wisdom, but this gtk+ installation problem remains clueless to me despite the kind post of frazap to share his experience (thanks!). So here I go.

      First, I'm running Strawberry Perl (64-bit) and my gtk+ version is 2.24.10.

      I followed the recipe up until launching the perl commands. Eg.

      c:\strawberry_perl\cpan\build\Cairo-1.106-0>echo %PKG_CONFIG_PATH%

      C:\strawberry_perl\c\lib\pkgconfig ; C:\Program Files\gtk+\lib\pkgconfig

      c:\strawberry_perl\cpan\build\Cairo-1.106-0>echo %PATH%


      Starting with Cairo: launch the perl command > fine.

      Running dmake: Strawberry complains that I should no longer use dmake but gmake. Fair enough, launch gamke instead and get “undefined reference” errors. Your help and wisdom would be greatly appreciated.



        Greetings, mtl3 and welcome to the monastery.

        The following instructions provide another way to install Perl-Gtk2 on the Windows platform. See, FAQ question #4.

        I tested on fresh Strawberry Perl installations v5.22.3.1, v5.24.2.1, and v5.26.0.2. During the Gtk2 installation, a new window may appear asking if you want to move the themes directory. If so, wait for the installation to finish before answering the question.

        The ppm_req script, mentioned in FAQ #4, is found here.

        > ppm install PPM::Sisyphusion Installing package 'PPM-Sisyphusion'... Bytes transferred: 496247 Installing C:\perl-\perl\site\lib\PPM\ Installing C:\perl-\perl\bin\lib530pthread-1.dll Installing C:\perl-\perl\bin\libgcc_sis__530.dll Installing C:\perl-\perl\bin\libstdc_530.dll > perl ppm_req Gtk2 # <-- provides a list of ppm commands to run > ppm install PPM::Sisyphusion::Cairo_font > ppm install Cairo > ppm install Gtk2 The following dependencies are installed automatically. > ppm install PPM::Sisyphusion::Pango_dll > ppm install PPM::Sisyphusion::Glib_dll > ppm install Glib > ppm install PPM::Sisyphusion::Gtk2_dll > ppm install PPM::Sisyphusion::Gtk2_theme > ppm install PPM::Sisyphusion::Cairo_dll > ppm install Pango

        Tk may be installed similarly, via PPM under Strawberry Perl v5.22.3.1, but not later Perl releases at this time. Trying will not hurt and simply emit a message stating not yet available.

        > ppm install PPM::Sisyphusion # <-- skip if already done > ppm install Tk > ppm install Tk::Zinc

        The list of Sisyphusion packages is found here.

        Regards, Mario

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1166929]
Approved by marto
Front-paged by Old_Gray_Bear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2018-07-17 12:00 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (363 votes). Check out past polls.