If you've been trying to use the
goncurses
library in your Go project, but kept encountering various ncurses related errors - such as missing .pc
files (ncurses.pc
, form.pc
, menu.pc
, panel.pc
) - then this post may help you get your Mac OS X, ncurses and golang installation running smoothly.Ncurses Library On Mac Os
A couple of weekends ago I decided that porting the classic UMoria game could teach me alot about Go. It all went swimmingly well - if somewhat boring at times - and finally last night I was able to get the code to compile without errors, Woot! But when trying to install goncurses I kept getting ncurses errors. Boo!
I'd experimented a little with goncurses a couple of months back and somehow go it working - for the life of me I don't now remember how. It was fun making my little
@
character run around the screen, but when I updated to Go 1.5, I'd reset my golang dev environment, which included deleting old sources.After several hours down the rabbit hole, I finally figured out what the issue was, and as I'm sure others have encountered these same problems, I wanted to share the solution here.
My current software versions are;
Curses.ncursesversion¶ A named tuple containing the three components of the ncurses library version: major, minor, and patch. All values are integers. The components can also be accessed by name, so curses.ncursesversion0 is equivalent to curses.ncursesversion.major and so on. Availability: if the ncurses library is used. Problem with curses library on Mac OS 10.2 darwin Hello, I am trying to write a simple program with functions in the ncurses library, on a Mac running OSX 10.2.8, with the compiler and libraries that were included in the Dec 2002 Developer's tools release (the last one that runs on Jaguar, as far as I know). Ncurses based System Performance Monitor for Darwin (Mac OS X) This is a near complete rewrite of nmon (file lmon15g.c dated 2015-07-13). The original nmon would not run under OS X since Darwin (the version of BSD which underlies Mac OS X) does not provide a /proc directory; system calls needed to replace the reading of files in the /proc directory. GNU Ncurses is a programming library that allows the users to write text-based user interfaces (TUI). Many text-based games have been created using this library. One popular example is PacVim, a CLI game to learn VIM commands. Sfott install yosemite beta dmg. In this brief tutorial, we will be discussing how to install Ncurses library in Unix-like operating systems.
- Mac OS X 10.9.5 (Mavericks)
- Homebrew 0.9.5
- Go 1.5
Golang NCurses support with goncurses
To use ncurses in your Go app you'll likely be using the goncurses library, which itself depends on the pkg-config utility and the C-ncurses package to be installed on your system. With OS X we can use Homebrew to install these;
At this point I'm presuming you already have Go installed and set up correctly (is your
$GOPATH
set?), so that we can use go get
to install the goncurses
library.On running that command you'll likely encounter the following error;
There are two different issues at work here.
PKG_CONFIG_PATH
has not been set to point to the.pc
files- Homebrew uses NCurses 6.0, which does not contain any
.pc
files.
We'll get to the
PKG_CONFIG_PATH
in a moment, but first we need to fix those missing .pc
files.As of August 12, 2015, Homebrew started shipping Ncures 6.0, and it seems that that version doesn't include the
.pc
files we need (5.9 does). Hopefully goncurses
will be updated soon to work with the latest release, but for now we need to create those files manually.I'll be keeping mine in my home directory under;
~/ncurses-pc-files
, but you can put yours in /usr/local/lib/pkgconfig
if you desire. So go ahead and create the following;![Mac Mac](https://www.ardanlabs.com/images/goinggo/Screen+Shot+2013-08-20+at+1.57.49+PM.png)
Note the
Cflags
setting. If you happen to have copied these files from ncurses v5.9 you'll likely encounter the following error when trying to get
the goncurses library;Adding
-I${includedir}/.
will solve that.Configuring the PKG_CONFIG_PATH
Now that we have our required
.pc
files we can go ahead and configure pkg-config
. Add the following export to your bash/zsh profile
config;NOTE: make sure to change that path to point to the location of the files you just created, and restart your terminal.
Installing the goncurses
library
With luck we'll be able to install goncurses without any further issues;
Ncurses Library On Mac Catalina
You should be presented with the command-prompt, without any errors or additional information.
I've not looked into how goncurses itself works so I'm not sure what will be needed to get it working with NCurses 6.0, but considering Homebrew now only provides that version for install, something will need to be changed. For now though, the above solution should work well enough to let you start experimenting with Go and ncurses on your Mac OS X.
Ncurses Library On Mac Mojave
- August 20, 2015 at 6:35pm
- Michael
- Tags: Golang, NCurses