Ehrweb.de

Perl and wxPerl (wxWidgets) on Mac (Apple Silicon)

This guide explains why the CPAN Wx module (wxPerl) often fails on macOS + Apple Silicon with the default stack (“CPAN Wx 0.9932 + current Homebrew wxWidgets”), and how to get a stable setup using Homebrew wxWidgets 3.2 and the sciurius fork.

Typical problems (Mac + Perl + wxWidgets)

Important: On current macOS, a stable solution is the sciurius/wxPerl fork (e.g. R3.005) together with sciurius/perl-Alien-wxWidgets (e.g. R0.73), not CPAN Wx 0.9932.

Recommended solution: Homebrew wxWidgets 3.2 + sciurius

1. Homebrew packages

brew install wxwidgets@3.2
            brew install cpanminus

On Apple Silicon, the 3.2 config binary is usually named wx-config-3.2:

ls "$(brew --prefix wxwidgets@3.2)/bin"

2. Environment variables (before every build/install)

export WX_CONFIG="/opt/homebrew/opt/wxwidgets@3.2/bin/wx-config-3.2"
            export PATH="/opt/homebrew/bin:$PATH"

On Intel Mac (/usr/local Homebrew), adjust paths accordingly. Check:

"$WX_CONFIG" --version
            file "$(which perl)"

3. Install Alien::wxWidgets and Wx (order matters)

Install Alien::wxWidgets first, then Wx:

cpanm --notest https://github.com/sciurius/perl-Alien-wxWidgets/archive/refs/tags/R0.73.tar.gz
            cpanm --notest https://github.com/sciurius/wxPerl/archive/refs/tags/R3.005.tar.gz
This project also contains cpanfile.wxperl, text docs in doku/wxperl-macos.txt, and a full build script shell/build-wxperl-macos.sh.

4. Test

perl -MWx -e 'print Wx::wxVERSION_STRING, "
            "'
            perl hello_world_wx.pl

In the sample script, use Wx ... and wx constants must be in the same package as OnInit (see hello_world_wx.pl).

Optional: historical CPAN 0.9932 Grid patch

If you still work with Wx 0.9932, see patches/wxperl-0.9932-wxwidgets32-macos.patch for Grid/typemap and GetViewWidth fixes. On macOS, this is usually not enough for a full successful build, so the sciurius fork remains the recommended path.