Reputation: 3484
I am trying to compile the following code in Cygwin 64 bit terminal using gcc, but it seems to be unable to find conio.h or dos.h
#include <stdlib.h>
#include <dos.h>
#define MEM 0X12
main()
{
struct WORDREGS
{
unsigned int ax;
unsigned int bx;
unsigned int cx;
unsigned int dx;
unsigned int si;
unsigned int di;
unsigned int flags;
};
struct BYTEREGS
{
unsigned char al,ah;
unsigned char bl,bh;
unsigned char cl,ch;
unsigned char dl,dh;
};
union REGS
{
struct WORDREGS x;
struct BYTEREGS h;
};
union REGS regs;
unsigned int size;
int86(MEM, ®s, ®s);
size = regs.x.ax;
printf("Memory size is %d Kbytes", size);
}
The compiler says it is unable to locate dos.h or conio.h, showing a fatal error notice. I want to know what the reason for this is and how it can be dealt with.
Upvotes: 0
Views: 3258
Reputation: 51
Cygwin is a Linux-Environment for Windows (see https://cygwin.com ). This is probably the main reason because there very well exists a header file called 'dos.h'.
Concerning the compilation problem a solution is explained in the mail archive of the cygwin mailing list ( https://www.cygwin.com/ml/cygwin/2007-04/msg00180.html ). It seems that dos.h and conio.h (header-files) are part of the mingw-runtime-WHATEVER.VERSION package, which you can download from cygwin.com (better install it with the cygwin install and update program setup-x86.exe or setup-x86_64.exe).
The link in that mail mentioned above is broken, but you can find the package by yourself, when choosing 'Search Packages' on the left side bar of the cygwin.com homepage. Then you can put 'dos.h' or 'conio.h' into the input field and after hitting 'Go' you get listed all packages, which contain these header files. According to the answer in that mail above, you only need the mingw-runtime-WHATEVER.VERSION package, which you have to download and install.
After installing that package you very probably need to instruct your gcc-compiler with the option '-I' (upper-case letter 'i'!) and the path (within quotation marks!) to the dos.h file, for instance:
gcc program.c -I'C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include'
Attention: Probably the path on your system is different, particularly when you are working with 64-bit-cygwin!
Instead of using the '-I' option, you can define an environment variable with following command in the terminal:
export C_INCLUDE_PATH='C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include'
At least the errors with the not found header-files are then eliminated, but there are probably still other errors (for instance: undefined reference to 'int86'?).
Upvotes: 3
Reputation: 53006
Because they are MS-DOS headers and are not available in cygwin. Also, the correct signature of main()
is int main()
.
Upvotes: 2