title: Using the g++ C++ compiler from cygwin
body: <p>I am trying to execute my first &quot;Hello World!&quot; in C++. I am using Windows XP, and I have installed cygwin, in which the g++ C++ compiler is installed. I have written a small hello-world program, and saved it in hello.cpp. From the command prompt I write:</p>
  <blockquote>
  <p>g++ hello.cpp</p>
  </blockquote>
  <p>But I get:</p>
  <blockquote>
  <p>'g++' is not recognized as an internal or external command, operable program or batch file.</p>
  </blockquote>
  <p>I have installed cygwin in my D:\programs\cygwin. I have made another directory with my hello-world file in D:\cpp. Something with my installation or my paths seems to be not Ok, but I cannot figure what. I have run the exe file of cygwin, and in the installation directory I have got all necessary files, I think: bin folder, lib, Cygwin.bat, etc.</p>
  <p>I have read that in case of such error message I should check whether the cygwin1.dll file is copied into the main folder of Windows. Is this the C:\WINDOWS directory? I have looked there, and I don't have such a file there. I have cygwin1.dll in the bin folder of cygwin: D:\programs\cygwin\bin.
  Also, how do I check whether the bin folder (D:\programs\cygwin\bin) is considered in the search path of commands?</p>
  <p>I think that the hello-world program shouldn't contain any syntax errors, I have just copied it. Also, when I write</p>
  <p>g++ -v</p>
  <p>I get the same error message: that the command is not recognized.
  I would appreciate if someone give me a hint what should I look at. Thank you.</p>
  <p>Here is the code of the hello-world program:</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
    cout &lt;&lt;&quot;Hello World!&quot;&lt;&lt;endl;
    return 0;
  }
  </code></pre>
  <p>I have installed g++, and now when I type g++ -v, I get: Reading specs from: \d\cygnus\cygwin-b20\H-i586-cygwin32\bin..\lib\gcc-lib\i586-cygwin32\egcs-2.91.57\specs gcc version egcs-2.91.57 19980901 (egcs-1.1 release)</p>
  <p>In the bin directory I have both g++.exe, and gcc.exe. I don't understand why I get &quot;gcc&quot; above and not &quot;g++&quot;. I don't know how important this is, but I receive an error message when I try to compile the program in the DOS command prompt:</p>
  <h3>g++ hello.cpp</h3>
  <p>I get:</p>
  <pre><code>hello.cpp:1: parse error before character 0357
  hello.cpp: In function 'int main()':
  hello.cpp:'cout' undeclared (first use this function)
  hello.cpp: (Each undeclared identifier is reported only once
  hello.cpp: for each function it appears in.)
  hello.cpp: 'endl' undeclared (first use this function)
  </code></pre>
  <p>And here is what I get when I try to compile the program in the cygwin shell:</p>
  <pre><code>hello.cpp:1: parse error before character 0357
  hello.cpp: In function 'int main()':
  hello.cpp:'cout' undeclared (first use this function)
  hello.cpp: (Each undeclared identifier is reported only once
  hello.cpp: for each function it appears in.)
  hello.cpp: 'endl' undeclared (first use this function)
  g++.exe: hello.cpp: No such file or directory
  g++.exe: No input files
  g++.exe: hello.cpp: No such file or directory
  g++.exe: No input files
  g++.exe: hello.cpp: No such file or directory
  g++.exe: No input files
  g++.exe: hello.cpp: No such file or directory
  g++.exe: No input files
  g++.exe: hello.cpp: No such file or directory
  g++.exe: No input files
  </code></pre>