Installing wxPerl for Strawberry Perl v5.32.0, or: Future of wxPerl?

I've been wanting to explore the Wx GUI toolkit bindings for Perl, but I couldn't get it to install correctly on my 64-bit Windows 7 machine.

When I ran cpan Wx, it failed to install the dependency Alien::wxWidgets. There were some cryptic errors about CreateProcess, which is (basically) Windows' equivalent of fork(2). Presumably, some process started by the build script was having some problems, but there wasn't much in the error message to go on.

From Google, I found an old reply posted on PerlMonks by Mark Dootson, the maintainer of Wx and Alien::wxWidgets, where he recommended to make sure to correctly set the PATH before building it.

Technically, my PATH seemed fine – it had all the necessary Perl directories in it. Still, suspecting that the problems may be caused by some other directory in the PATH, I reduced it to its bare elements and then ran cpan again:

C:\>set PATH=C:\Windows\system32;C:\Windows;C:\Perl\c\bin;C:\Perl\perl\site\bin;C:\Perl\perl\bin
C:\>cpan
cpan>install Alien::wxWidgets

It worked! I suspect that some file in C:\Perl\c\bin (of which there are 113) was overridden by some other file in my PATH.

Now, onto the next problem: apparently the Wx module itself doesn't compile successfully on recent (5.30+) versions of (Strawberry?) Perl. As I understand it, the problem is that a new calloc macro has been added to the Perl source. To fix this, you need to edit the source code of the file cpp/wxapi.h and simply add the following:

#undef calloc

You can start a subshell in the build directory by issuing cpan the command look Wx. After making the edit, you can build, test and install Wx by issuing the following commands:

gmake test install

All this should result in a successful wxPerl installation – problem solved.

Well, sort of. This has left me wondering why this simple patch hasn't been applied to the Wx module yet. The solution (linked here again) was posted on the bug tracker for Wx in July of 2019. The last release of Wx was in April of 2017.

There doesn't seem to be any maintainers other than Mark Dootson. Perhaps he and wxPerl would be helped by somebody else getting involved.

4 Comments

I've had this class of problem on macOS too. Raku's configure script would find a mix of tools from gcc and clang.

Ah, I actually found the link: https://stackoverflow.com/questions/34781571/why-does-moarvm-complain-about-built-for-archive-which-is-not-the-architecture/35094347#35094347

Thanks for this...though I don't use Windows, the installation in Linux had been equally tricky. I found that I couldn't get WxImage to work...you had to use Jouke's version Wx::Perl::Imagick.

The easiest GUI in Windows is probably Win32::GUI. Tk is more cross-platform though looks dated.

I will "borrow" your suggestions for my applications, thanks. But like you, hope that some clever person might be able step up to help maintain Wx and pull these mods.

The real question is whether there is interest in Perl GUI applications. Personally I like to use (and create) Perl applications that use wxWidgets so I can deploy them on Linux, MacOS and Windows. But I may very well be the last member of a near extinct race. Even flagship tools like Padre seem to be abandoned. AFAIK there are no Raku plans for wxWidgets.

So it's a vicious circle. No Wx → no apps, no apps → no Wx.

A getting together of people interested in Perl/Raku GUI applications would be a first step.

Many thanks John. Times like this make me think about learning python.

For others trying to get this working here is my recipe:


1) set path so powershell and wbem don't interfere (still needed for downloads to work):

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\Users\USER\bin;C:\WINDOWS\System32\OpenSSH\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Users\USER\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;


2) do cpan install which will take over an hour(med fast pc in a VM) and spew _many_ errors and eventually fail (but all necessary files will download)

C:\Users\USER>cpan -i Wx

# this will fail
#NOTE: every time you run this it generates
#a new Wx-0.9932-X dir and in it a new
#wxapi.h, so just run it once and let
#it complete..

3) edit the wxapi.h file to undef calloc

> cd C:\Strawberry\cpan\build\Wx-0.9932-0\cpp
> vi wxapi.h
:133
#copy paste "undef malloc" line and change
#to "undef calloc" with a c instead of an m


4) do not run cpan -i Wx again!!! instead do the following

> cpan
cpan> look Wx
# this entered the latest Wx dir (for me -3)
cpan> perl Makefile.pl
# this generates make file necessary for following
cpan> gmake install test

# everything that is touched by wxapi.h will be recompiled,
#it will take about 15 mins this time, all tests should pass


Repeated to remove truncation seen in comment preview (remove newlines):

set PATH=
C:\WINDOWS\system32;
C:\WINDOWS;
C:\Users\USER\bin;
C:\WINDOWS\System32\OpenSSH\;
C:\Strawberry\c\bin;
C:\Strawberry\perl\site\bin;
C:\Strawberry\perl\bin;
C:\Users\USER\AppData\Local\Microsoft\WindowsApps;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;

Leave a comment

About John Ankarström

user-pic Student of linguistics, hobbyist programmer. Unix on the server, Windows on the desktop.