Xu Wang
Xu Wang

Reputation: 10597

How to print version of ncurses from Perl

How can I print the version of the ncurses library? I use the Curses library from Perl. I do not care much about the version of the CTAN package which from what I understand is just the interface to access the curses library.

I downloaded the latest (unstable) version of ncurses from here: http://invisible-island.net/datafiles/current/ncurses.tar.gz

I compiled it without error (with just ./configure and make) but have not yet done sudo make install

I would like to know how to (1) check which version of curses is installed and eventually (2) switch between versions.

Note that I am on Ubuntu 13.04. Perhaps the following information is helpful:

$ locate ncurses.h
/usr/include/ncurses.h
$ locate curses.h
/usr/include/curses.h
/usr/include/ncurses.h
/usr/include/python2.7/py_curses.h
$ 

Upvotes: 0

Views: 1291

Answers (2)

Slaven Rezic
Slaven Rezic

Reputation: 4581

It seems that indeed there is no function in Curses.pm to get the current (n)curses version. You can write a small C program to get the value:

/* compile with "cc -lcurses filename.c" */
#include <curses.h>
main() {
  printf("%s\n", curses_version());
}

On my system this prints ncurses 5.7.20100313.

But it would also be nice to have the curses_version() function also available from Curses.pm — maybe ask the Curses.pm author?

Upvotes: 2

Christian
Christian

Reputation: 73

Do you have ncurses5-config (or ncurses-config, ncurses4-config, etc...) on your system? I for instance can do this on my CentOS 6 system:

$ ncurses5-config --version
5.7.20090207

which you could call from perl also:

my $ncurses_version = qx(ncurses5-config --version);

If you are working with different major versions, you might have to try a couple ncurses*-config commands, e.g.:

my $nc_version;
for my $nc (qw'ncurses-config ncurses5-config ncurses4-config') {
  no warnings 'exec';
  $nc_version = qx($nc --version) and last;
}
print "nc_version=$nc_version\n";

Hope this helps you, Christian

Upvotes: 2

Related Questions