Skip to content

Instantly share code, notes, and snippets.

@V0XNIHILI
Last active September 2, 2024 17:04
Show Gist options
  • Save V0XNIHILI/61d1e46684de56357990b5f75a14b8cc to your computer and use it in GitHub Desktop.
Save V0XNIHILI/61d1e46684de56357990b5f75a14b8cc to your computer and use it in GitHub Desktop.
How to compile GTKWave for Apple Silicon (M1/M2/M3 Macs)

How to compile GTKWave for Apple Silicon (M1/M2/M3 Macs)

Based on this tutorial for the M1 Mac, find below a step-by-step guide on how to compile GTKWave from scratch for the M3 MacBook (Pro). See my LinkedIn post with the short announcement here.

Note: it is a prerequisite to have HomeBrew installed (find installation instructions at site).

Steps

1. Install required Homebrew packages

brew install gtk+3 gtk-mac-integration tcl-tk desktop-file-utils meson cmake pango libffi zlib expat shared-mime-info

2. Set linker, compiler and package environment variables

export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"
export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:/opt/homebrew/opt/libffi/lib/pkgconfig:/opt/homebrew/opt/zlib/lib/pkgconfig:/opt/homebrew/opt/gtk+3/lib/pkgconfig:/opt/homebrew/opt/expat/lib/pkgconfig"

3. Build, compile and install GTKWave

git clone "[email protected]:gtkwave/gtkwave.git"
cd gtkwave
meson setup build -Dintrospection=false
meson compile -C build
meson install -C build

4. Run GTKWave!

gtkwave
@MicroGrit
Copy link

When executing the command meson install -C build, if an error is reported, how can this issue be resolved?

Dropping privileges to 'w' before running ninja...
ninja: Entering directory `/Users/w/workshop/workshop/gtkwave/build'
[20/20] Generating lib/libgtkwave/test/generate-dump-timezero.fst with a custom command (wrapped by meson to set env, to capture output)
Installing lib/libgtkwave/src/libgtkwave.dylib to /opt/homebrew/lib
Installing src/helpers/evcd2vcd to /opt/homebrew/bin
Installing src/helpers/fst2vcd to /opt/homebrew/bin
Installing src/helpers/fstminer to /opt/homebrew/bin
Installing src/helpers/lxt2miner to /opt/homebrew/bin
Installing src/helpers/lxt2vcd to /opt/homebrew/bin
Installing src/helpers/vcd2fst to /opt/homebrew/bin
Installing src/helpers/vcd2lxt to /opt/homebrew/bin
Installing src/helpers/vcd2lxt2 to /opt/homebrew/bin
Installing src/helpers/vcd2vzt to /opt/homebrew/bin
Installing src/helpers/vzt2vcd to /opt/homebrew/bin
Installing src/helpers/vztminer to /opt/homebrew/bin
Installing src/gtkwave to /opt/homebrew/bin
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.12/site-packages/mesonbuild/mesonmain.py", line 188, in run
return options.run_func(options)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/mesonbuild/minstall.py", line 869, in run
installer.do_install(datafilename)
File "/opt/homebrew/lib/python3.12/site-packages/mesonbuild/minstall.py", line 549, in do_install
self.install_targets(d, dm, destdir, fullprefix)
File "/opt/homebrew/lib/python3.12/site-packages/mesonbuild/minstall.py", line 746, in install_targets
file_copied = self.do_copyfile(fname, outname, makedirs=(dm, outdir))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/mesonbuild/minstall.py", line 426, in do_copyfile
self.copy2(from_file, to_file)
File "/opt/homebrew/lib/python3.12/site-packages/mesonbuild/minstall.py", line 323, in copy2
shutil.copy2(*args, **kwargs)
File "/opt/homebrew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/shutil.py", line 475, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/opt/homebrew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/shutil.py", line 262, in copyfile
with open(dst, 'wb') as fdst:
^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/opt/homebrew/bin/gtkwave'

ERROR: Unhandled python OSError. This is probably not a Meson bug, but an issue with your build environment.

@V0XNIHILI
Copy link
Author

Hey, thanks for checking out this Gist! I just found this page, but maybe you have come across it as well: https://github.com/orgs/Homebrew/discussions/4578

Let me know if manage to solve it!

@Kurumiiw
Copy link

Kurumiiw commented Sep 2, 2024

I had the same error as @MicroGrit , it turns out the directory was already populated with a gtkwave. (Probably from a previous installation attempt?)

I fixed it by simply doing rm /opt/homebrew/bin/gtkwave, and then running meson install -C build again.
Hope this helps.

Thank you for the rundown @V0XNIHILI ! I had issues getting gtkwave to run on my M1 but this fixed my issues and I have a working build now.

@V0XNIHILI
Copy link
Author

@Kurumiiw happy to hear, enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment