Hi, I am a COMPLETE newby at programming but am trying hard to get as far as I can on my own. I have installed Cygwin, with the gcc compiler package, and it all seems to be working OK. I'm using the 'Hello World' sample program used in the tutorial here - code is as follows:
// my first program in C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
I have saved the text to file c:\cygwin\hello.c, then from within Cygwin I have typed:
gcc /hello.c -o hello.exe. I get the following error messages:
/hello.c:3:20 iostream: No such file or directory
/hello.c:4: error: parse error before "namespace"
/hello.c:4: warning: data definition has no type or storage class
/hello.c: In function 'main':
/hello.c:8: error: 'cout' undeclared (first use in this function)
/hello.c:8: error (Each undeclared identifier is reported only once
/hello.c:8: error for each function it appears in.)
After searching for some answers with Google, I found several others having similar problems. The suggested answers for them did not work for me. One suggested solution was that the iostream library was not installed. I installed the ENTIRE 800 mb Cygwin package, including all libraries. Another suggestion was that it was a pathing issue. I do think I have a pathing issue, or I wouldn't have to use the leading '/' before hello.c - i should be able to use:
gcc hello.c -o hello.exe. But I don't know what else to do about the pathing - I added C:\Cygwin, and C:\Cygwin\home\username\ to my set path environment variable and rebooted Win XP Pro SP3.
The reason I said Cygwin seems to be working OK is that this other program works correctly (taken from Cygwin's User's guide):
http://cygwin.com/cygwin-ug-net/setup-maxmem.html
main()
{
unsigned int bit=0x40000000, sum=0;
char *x;
while (bit > 4096)
{
x = malloc(bit);
if (x)
sum += bit;
bit >>= 1;
}
printf("%08x bytes (%.1fMb)\n", sum, sum/1024.0/1024.0);
return 0;
}
It both compiles and executes properly.
If someone could help straighten me out on this, I'd love to move past step one in learning how to program!
Thank you, Ken