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)
-
CPAN Wx 0.9932 is not fully adapted for
wxWidgets 3.2/3.3 on macOS: failures in
Alien::wxWidgets (missing
advlibrary mapping), then in Grid.c (GetViewWidth,wxGridCellEditorvswxClientDataContainertype assumptions). -
Even after manual Grid fixes, more compile errors usually appear in
core modules (e.g.
Frames.c,GDI.c) — the official CPAN release is not suitable as-is for wx 3.2 on macOS. -
Homebrew
wxwidgets(3.3.x) andwxwidgets@3.2side-by-side: the recommended wxPerl fork requires wxWidgets 3.2; it is not meant for versions older than 3.2. -
Perl architecture: as with Tk,
perlshould be arm64 to match Homebrew libraries.
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
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.