Click to See Complete Forum and Search --> : Ncurses & c++


arlenagha
12-06-2002, 10:15 PM
Hello everyone.
As far as i know ncurses is written in c, so is there a point in trying to learn it if i only know c++??

is there another library like ncurses that is written in c++ that i can use???

EscapeCharacter
12-07-2002, 02:28 AM
well theoretically c++ can do everything c can so yes. there isnt however a ncurses++ library(that i know of), you would probably have to write wrapper functions or just call the c ncurses calls

bwkaz
12-07-2002, 09:39 AM
When ncurses is compiled from source, there is a configure option --without-cxx-binding that disables the C++ bindings (in other words, the C++ interface) and demo programs.

I don't know where your distro would have put it, but you might consider trying to compile a version of ncurses from source. You can download the tarball from ftp://ftp.gnu.org/gnu/ncurses/

However, I haven't tried version 5.3 yet, so I'm not positive that there aren't any gotchas with it. With 5.2, make sure you have gpm-devel installed, and make sure you pass --with-gpm to the configure command, or you won't be able to use mouse in ncurses programs. That may or may not be a big deal. You'll also want to use --with-shared and possibly --with-libtool, to generate a shared library (with libtool). Also, --disable-termcap (termcap is deprecated in favor of terminfo, and the ncurses package installs a terminfo database for you) and --enable-symlinks (without that one, all the links in the terminfo database are hard links, which sometimes gets confusing. Personally, I find it easier when they're symlinks instead).

As a last option, you'll probably want --prefix=/usr to overwrite your current libncurses.so files. If you don't overwrite them, there's a chance that the wrong lib will get linked to your program.

So the configure would seem to look like ./configure --prefix=/usr --with-gpm --with-shared --with-libtool --disable-termcap --enable-symlinks in the end. You might also read the output of ./configure --help to see if there's anything else you should install.

Once you've done this, check around in /usr/lib for a libncurses++.so file, or something like that. Also check in the directory you unpacked ncurses to, for some examples of how to use the C++ binding.