You basically have 2 choices on how to proceed. You can either install a package that includes
conio.h + its library as I describe below or you can use
ncurses.h + its library and swap out and/or remove function calls that depend on it as @Ashish Kulkarni describes in his answer. Either option is viable and is up to the developer/implementer to decide which is the "correct" path.
conio.h header + library for C/C++ is not something you'll typically find as being installed by default with most Linux distros. At least not the ones that I'm familiar with Fedora/CentOS/RHEL/Debian/Ubuntu.
NOTE:: Also the use of
ncurses.h is not appropriate here either, since that library will likely not include any of the functions that you're looking for (
getch(), etc.) since your
.cpp file would seem to be coming from a Windows environment originally.
However you have the option with Linux to install packages from centrally managed repositories. Looking for a package that includes
conio.h on my Fedora system I turned up this package. I realize you're on Ubuntu but on Fedora the package is called
libconio that provides exactly the libraries that you're looking for.
$ yum info libconio.i686
Loaded plugins: auto-update-debuginfo, changelog, langpacks, refresh-packagekit
Name : libconio
Arch : i686
Version : 1.0.0
Release : 3.2
Size : 6.3 k
Repo : rpm-sphere
Summary : Implementation of conio.h functions
License : GPL
Description : libconio is an implementation of conio.h functions that some
: DOS and Windows compilers provide. It's purpose is to allow
: developers to use functions like getch, getche, textcolor and
: others in a linux environment.
Looking on a Ubuntu system I have there's a similar package called
elks-libc that also contains
$ apt-cache show elks-libc
Maintainer: Ubuntu Developers <firstname.lastname@example.org>
Original-Maintainer: Juan Cespedes <email@example.com>
Replaces: bcc (<< 0.14.9), linux86
Recommends: bcc (= 0.16.17-3.1ubuntu3)
Description-en: 16-bit x86 C library and include files
This is the C library used to compile with bcc. It includes all the
headers and static libraries needed to build 16-bit applications,
for Linux/8086, Linux/i386 and DOS .COM executables.
And here's the file:
$ apt-file list elks-libc | grep conio.h
So you can simply install this package to get the header file + libraries that your application requires to compile.
$ sudo apt-get install elks-libc
NOTE: You may need to adjust your include path to
gcc to pick this header file up.
elks-libc is only for 8088 Intel processors
As mentioned in the comments,
elks-libc is intended for use on system's that are targeting the Intel 8088 CPU. You can instead download
libconio.h from the SourceForge project titled: Linux c++ implementation of conio.h. You'll have to install it manually but it shouldn't be too difficult to do this.
Simple Linux implementation of Borland's conio (conio.h) library. It uses Ncurses. It includes most functions required to write a basic application using conioh (i.e. getch(), cprintf(), puts() and more).
You can also get the entire
libconio project's source from this SourceForge project titled: libconio and unpack it.
Details on doing this as well as building it and compiling it are covered in this tutorial titled: How to use with GCC.