2022年1月2日 星期日

[NetHack] How to build NetHack 3.7 with Qt on macOS

Listed libraries are key requirements
You might need another libraries to finish the build

Install Xcode from App Store or gcc from MacPorts 
Make sure the executables are added to $PATH
$ whereis gcc
/usr/bin/gcc
$ whereis clang
/usr/bin/clang exists 

Download the source code from github
$ git clone git@github.com:NetHack/NetHack.git
$ cd NetHack
$ git checkout NetHack-3.7

Download lua submodule
$ git submodule init
$ git submodule update --recursive

Download qt5 from MacPorts
Qt5 will be installed in /opt/local/libexec/qt5
Make sure the path exists
$ sudo port install qt5 

Generate Makefile
$ sh sys/unix/setup.sh sys/unix/hints/macOS.370

Edit <NetHack source root>/Makefile with familiar editor
uncomment #WANT_WIN_QT=1 
uncomment #WANT_DEFAULT=Qt
uncomment #QTDIR=/opt/local/libexec/qt5

$ make
This should work
Wait until the build finishes

$ make install
My experience is the final product lies in /Users/<user>/nethackdir
Kindly tell me if you find it in another place, thanks in advance