6

I'm trying to run my C++ code using the console. I used the header file conio.h like I did when I used Turbo C++ IDE in Windows, and I ran the code in console using

g++ filename.cpp

I have installed build-essentials Install build-essentials previously, but still I get the message:

conio.h file : No such file or directory

I have poked around a bit and learned that the header files for Windows and Linux differs, but am still to find a way to get all the header files required for basic and intermediate coding practice.

Help on this is appreciated. Please keep in mind that I'm very new to Ubuntu.

6

conio.h is a library that is windows specific. To my knowledge it comes with mingw32, a compiler that is a windows port of gcc. Try to set up your code so that it doesn't use it.

Also, note that linux uses (99% of the time) the gnu standard library (gnulibc). You can find its content here


For input/output you'd need the iostream (not iostream.h) header file. You can look at a more elaborate and complete list here.

  • So could you please make clear what are the basic header files that are required to run a cpp program (basic I/O and so forth) ? And is ncurses package really required as I read elsewhere? – root_access Feb 6 '13 at 12:15
  • updated the answer. – green Feb 6 '13 at 12:19
  • Afaik conio.h is not included in minGW, It is difficult to implement conio.h functions using iostream, so you should use ncurses or similar libraries for this purpose – Tachyons Feb 6 '13 at 12:59
  • thank you @green7 , the link is quite comprehensive and was one of the things I was looking for. Could you please tell me which package I need to install for the standard library header files to be available? Or is it already in the build-essentials package that I have installed? – root_access Feb 6 '13 at 13:31
  • You don't need to install anything. Just write the program and compile it using g++ – green Feb 6 '13 at 14:28
1

conio.h is turbo c++ specific header file, it is not a standard c++ header file

usage #include<headerfile.h> is no longer supported in c++, It is replaced by #include<headerfile>

Eg: use #include<iostream> instead of #include<iostream.h>

You can run turbo c++ in linux using dosbox, But it is highly discouraged, Always use standard syntax while learning a programming language

  • #include instead of #include? please review your comment. Thanks. – root_access Feb 6 '13 at 13:51
0

The <iostream.h> header is old and deprecated. Instead you should use <iostream> which is the new header. If you still get an error about your header file then check your include directories. Go to "Option" > "Directories..." and check your "Include Directories" for example: /home/user/cpp/custom-includes/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.