public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Won't compile the simplest of progs.
@ 1999-09-16  6:08 Earnie Boyd
  1999-09-30 23:42 ` Earnie Boyd
  0 siblings, 1 reply; 8+ messages in thread
From: Earnie Boyd @ 1999-09-16  6:08 UTC (permalink / raw)
  To: Daniel Harry Hawson

--- Daniel Harry Hawson <u7dhh@dcs.shef.ac.uk> wrote:
> I have a 'Progs' folder in my 'cygwin-b20' folder.
> In 'Progs', I tried to compile a C++ file called 'Keypress.cpp'.
> 
> >   BASH.EXE-2.02$ gcc -o Progs/key.exe Progs/keypress.cpp
> >   Progs/keypress.cpp:1: conio.h: No such file or directory
> >   BASH.EXE-2.02$
> 
> What am I doing wrong?
> 
> Here is the contents of 'Keypress.cpp' -
> 
> >  #include <conio.h>
> >  #include <iostream.h>
> >  
> >  int main(void)
> >  {
> >    int c;
> >    c = getch();
> >    while (c != 27)	//27 = esc
> >    {
> >  	cout<<"pressed :"<<c<<'\n';
> >  	c = getch();
> >    }
> >    return 0;
> >  }
> 
> Will CygWin work with C++ or just C code?
> How can I get this to work?

This will most likely work with the Mingw32 package which you can download from
Mumit Khan's site.  His URL is listed at my site.

===
Earnie Boyd < mailto:earnie_boyd@yahoo.com >

Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >

(If you respond to the list, then please don't cc me)
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Won't compile the simplest of progs.
  1999-09-16  6:08 Won't compile the simplest of progs Earnie Boyd
@ 1999-09-30 23:42 ` Earnie Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Earnie Boyd @ 1999-09-30 23:42 UTC (permalink / raw)
  To: Daniel Harry Hawson, cygwin

--- Daniel Harry Hawson <u7dhh@dcs.shef.ac.uk> wrote:
> I have a 'Progs' folder in my 'cygwin-b20' folder.
> In 'Progs', I tried to compile a C++ file called 'Keypress.cpp'.
> 
> >   BASH.EXE-2.02$ gcc -o Progs/key.exe Progs/keypress.cpp
> >   Progs/keypress.cpp:1: conio.h: No such file or directory
> >   BASH.EXE-2.02$
> 
> What am I doing wrong?
> 
> Here is the contents of 'Keypress.cpp' -
> 
> >  #include <conio.h>
> >  #include <iostream.h>
> >  
> >  int main(void)
> >  {
> >    int c;
> >    c = getch();
> >    while (c != 27)	//27 = esc
> >    {
> >  	cout<<"pressed :"<<c<<'\n';
> >  	c = getch();
> >    }
> >    return 0;
> >  }
> 
> Will CygWin work with C++ or just C code?
> How can I get this to work?

This will most likely work with the Mingw32 package which you can download from
Mumit Khan's site.  His URL is listed at my site.

===
Earnie Boyd < mailto:earnie_boyd@yahoo.com >

Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >

(If you respond to the list, then please don't cc me)
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Won't compile the simplest of progs.
  1999-09-16  2:48 ` Gabriel Galibourg
@ 1999-09-30 23:42   ` Gabriel Galibourg
  0 siblings, 0 replies; 8+ messages in thread
From: Gabriel Galibourg @ 1999-09-30 23:42 UTC (permalink / raw)
  To: Daniel Harry Hawson; +Cc: cygwin

Yes cygwin (well really gcc) compiles C and C++ code, altough I prefer to use gcc when compiling C code and g++ when compiling C++ code (helps the linker get it right).

The problem with your code is that you are using a windows function (getch()) which does not exist in cygwin (or Unix). The 'proper' Unix way to get simple character input would be to put your terminal in non-canonical mode (stty -icanon min 1 time 0), you can do this within a C/C++ program by using ioctl() (but I've never done it under cygwin so I ignore if it works).
So to keep the story short, to get your program to work do the following:
1) remove the #include <conio.h> since cygwin doesn't know about it - you could put the full path to it (in your msdev directories) - but I don't think that would help much
2) change your call to getch() to _getch() - which is the 'real' library function (getch() is merely a #define to it)
3) compile the following way:
g++ -o Progs/key.exe Progs/keypress.cpp -lmsvcrt
You need to link with msvcrt which is where _getch() is defined. You'll also get a warning about the implicit declaration of _getch(), you can always clean this up later by creating you own conio.h with the good stuff in it.

The resulting program works fine under a 'normal' command prompt (cmd.exe) but does not work very well under the cygwin bash .

Gabriel.

> Daniel Harry Hawson wrote:
>
> > I have a 'Progs' folder in my 'cygwin-b20' folder.
> > In 'Progs', I tried to compile a C++ file called 'Keypress.cpp'.
> >
> > >   BASH.EXE-2.02$ gcc -o Progs/key.exe Progs/keypress.cpp
> > >   Progs/keypress.cpp:1: conio.h: No such file or directory
> > >   BASH.EXE-2.02$
> >
> > What am I doing wrong?
> >
> > Here is the contents of 'Keypress.cpp' -
> >
> > >  #include <conio.h>
> > >  #include <iostream.h>
> > >
> > >  int main(void)
> > >  {
> > >    int c;
> > >    c = getch();
> > >    while (c != 27)    //27 = esc
> > >    {
> > >       cout<<"pressed :"<<c<<'\n';
> > >       c = getch();
> > >    }
> > >    return 0;
> > >  }
> >
> > Will CygWin work with C++ or just C code?
> > How can I get this to work?
> >
> > Thanks.
> >
> > Dan
> > u7dhh@dcs.shef.ac.uk
> >
> > --
> > Want to unsubscribe from this list?
> > Send a message to cygwin-unsubscribe@sourceware.cygnus.com


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Won't compile the simplest of progs.
  1999-09-16  5:59 Earnie Boyd
@ 1999-09-30 23:42 ` Earnie Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Earnie Boyd @ 1999-09-30 23:42 UTC (permalink / raw)
  To: gabriel, Daniel Harry Hawson; +Cc: cygwin

--- Gabriel Galibourg <gabriel@solfin.com> wrote:
> 3) compile the following way:
> g++ -o Progs/key.exe Progs/keypress.cpp -lmsvcrt
> You need to link with msvcrt which is where _getch() is defined. You'll also
> get a warning about the implicit declaration of _getch(), you can always
> clean this up later by creating you own conio.h with the good stuff in it.
> 
> The resulting program works fine under a 'normal' command prompt (cmd.exe)
> but does not work very well under the cygwin bash .
> 
> Gabriel.

NO! Don't mix runtime systems.  You will cause more headaches than you can
imagine.  If you need to use the msvcrt/crtdll functions use the Mingw32
package or the -mno-cygwin switch.  For detail see Mumit Khans site.


===
Earnie Boyd < mailto:earnie_boyd@yahoo.com >

Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >

(If you respond to the list, then please don't cc me)
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Won't compile the simplest of progs.
  1999-09-15  4:31 Daniel Harry Hawson
  1999-09-16  2:48 ` Gabriel Galibourg
@ 1999-09-30 23:42 ` Daniel Harry Hawson
  1 sibling, 0 replies; 8+ messages in thread
From: Daniel Harry Hawson @ 1999-09-30 23:42 UTC (permalink / raw)
  To: cygwin

I have a 'Progs' folder in my 'cygwin-b20' folder.
In 'Progs', I tried to compile a C++ file called 'Keypress.cpp'.

>   BASH.EXE-2.02$ gcc -o Progs/key.exe Progs/keypress.cpp
>   Progs/keypress.cpp:1: conio.h: No such file or directory
>   BASH.EXE-2.02$

What am I doing wrong?

Here is the contents of 'Keypress.cpp' -

>  #include <conio.h>
>  #include <iostream.h>
>  
>  int main(void)
>  {
>    int c;
>    c = getch();
>    while (c != 27)	//27 = esc
>    {
>  	cout<<"pressed :"<<c<<'\n';
>  	c = getch();
>    }
>    return 0;
>  }

Will CygWin work with C++ or just C code?
How can I get this to work?

Thanks.

Dan
u7dhh@dcs.shef.ac.uk

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Won't compile the simplest of progs.
@ 1999-09-16  5:59 Earnie Boyd
  1999-09-30 23:42 ` Earnie Boyd
  0 siblings, 1 reply; 8+ messages in thread
From: Earnie Boyd @ 1999-09-16  5:59 UTC (permalink / raw)
  To: gabriel; +Cc: cygwin

--- Gabriel Galibourg <gabriel@solfin.com> wrote:
> 3) compile the following way:
> g++ -o Progs/key.exe Progs/keypress.cpp -lmsvcrt
> You need to link with msvcrt which is where _getch() is defined. You'll also
> get a warning about the implicit declaration of _getch(), you can always
> clean this up later by creating you own conio.h with the good stuff in it.
> 
> The resulting program works fine under a 'normal' command prompt (cmd.exe)
> but does not work very well under the cygwin bash .
> 
> Gabriel.

NO! Don't mix runtime systems.  You will cause more headaches than you can
imagine.  If you need to use the msvcrt/crtdll functions use the Mingw32
package or the -mno-cygwin switch.  For detail see Mumit Khans site.


===
Earnie Boyd < mailto:earnie_boyd@yahoo.com >

Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >

(If you respond to the list, then please don't cc me)
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Won't compile the simplest of progs.
  1999-09-15  4:31 Daniel Harry Hawson
@ 1999-09-16  2:48 ` Gabriel Galibourg
  1999-09-30 23:42   ` Gabriel Galibourg
  1999-09-30 23:42 ` Daniel Harry Hawson
  1 sibling, 1 reply; 8+ messages in thread
From: Gabriel Galibourg @ 1999-09-16  2:48 UTC (permalink / raw)
  To: Daniel Harry Hawson; +Cc: cygwin

Yes cygwin (well really gcc) compiles C and C++ code, altough I prefer to use gcc when compiling C code and g++ when compiling C++ code (helps the linker get it right).

The problem with your code is that you are using a windows function (getch()) which does not exist in cygwin (or Unix). The 'proper' Unix way to get simple character input would be to put your terminal in non-canonical mode (stty -icanon min 1 time 0), you can do this within a C/C++ program by using ioctl() (but I've never done it under cygwin so I ignore if it works).
So to keep the story short, to get your program to work do the following:
1) remove the #include <conio.h> since cygwin doesn't know about it - you could put the full path to it (in your msdev directories) - but I don't think that would help much
2) change your call to getch() to _getch() - which is the 'real' library function (getch() is merely a #define to it)
3) compile the following way:
g++ -o Progs/key.exe Progs/keypress.cpp -lmsvcrt
You need to link with msvcrt which is where _getch() is defined. You'll also get a warning about the implicit declaration of _getch(), you can always clean this up later by creating you own conio.h with the good stuff in it.

The resulting program works fine under a 'normal' command prompt (cmd.exe) but does not work very well under the cygwin bash .

Gabriel.

> Daniel Harry Hawson wrote:
>
> > I have a 'Progs' folder in my 'cygwin-b20' folder.
> > In 'Progs', I tried to compile a C++ file called 'Keypress.cpp'.
> >
> > >   BASH.EXE-2.02$ gcc -o Progs/key.exe Progs/keypress.cpp
> > >   Progs/keypress.cpp:1: conio.h: No such file or directory
> > >   BASH.EXE-2.02$
> >
> > What am I doing wrong?
> >
> > Here is the contents of 'Keypress.cpp' -
> >
> > >  #include <conio.h>
> > >  #include <iostream.h>
> > >
> > >  int main(void)
> > >  {
> > >    int c;
> > >    c = getch();
> > >    while (c != 27)    //27 = esc
> > >    {
> > >       cout<<"pressed :"<<c<<'\n';
> > >       c = getch();
> > >    }
> > >    return 0;
> > >  }
> >
> > Will CygWin work with C++ or just C code?
> > How can I get this to work?
> >
> > Thanks.
> >
> > Dan
> > u7dhh@dcs.shef.ac.uk
> >
> > --
> > Want to unsubscribe from this list?
> > Send a message to cygwin-unsubscribe@sourceware.cygnus.com


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Won't compile the simplest of progs.
@ 1999-09-15  4:31 Daniel Harry Hawson
  1999-09-16  2:48 ` Gabriel Galibourg
  1999-09-30 23:42 ` Daniel Harry Hawson
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel Harry Hawson @ 1999-09-15  4:31 UTC (permalink / raw)
  To: cygwin

I have a 'Progs' folder in my 'cygwin-b20' folder.
In 'Progs', I tried to compile a C++ file called 'Keypress.cpp'.

>   BASH.EXE-2.02$ gcc -o Progs/key.exe Progs/keypress.cpp
>   Progs/keypress.cpp:1: conio.h: No such file or directory
>   BASH.EXE-2.02$

What am I doing wrong?

Here is the contents of 'Keypress.cpp' -

>  #include <conio.h>
>  #include <iostream.h>
>  
>  int main(void)
>  {
>    int c;
>    c = getch();
>    while (c != 27)	//27 = esc
>    {
>  	cout<<"pressed :"<<c<<'\n';
>  	c = getch();
>    }
>    return 0;
>  }

Will CygWin work with C++ or just C code?
How can I get this to work?

Thanks.

Dan
u7dhh@dcs.shef.ac.uk

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1999-09-30 23:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-16  6:08 Won't compile the simplest of progs Earnie Boyd
1999-09-30 23:42 ` Earnie Boyd
  -- strict thread matches above, loose matches on Subject: below --
1999-09-16  5:59 Earnie Boyd
1999-09-30 23:42 ` Earnie Boyd
1999-09-15  4:31 Daniel Harry Hawson
1999-09-16  2:48 ` Gabriel Galibourg
1999-09-30 23:42   ` Gabriel Galibourg
1999-09-30 23:42 ` Daniel Harry Hawson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).