This is the first time that I'm using the g++ compiler to compile my c++ programs. I have installed cygwin g++. and I'm trying to run a very simple program to display "hello", to see wether it would work.

The problem is that whatever path that I type in I get the error:

*-bash: cd: c:program: No such file or directory*

The path I typed in is

*$ cd c:\program files\internet explorer*

Thats where I installed cygwin into. But for some reason it's not working the way it should. Can anyone help me out here?

  • 2
    I recommend you install cygwin to C:\Cygwin (or some other directory without spaces). See cygwin.com/cygwin-ug-net/using.html#pathnames-win32 for information about Windows paths
    – larsm
    Commented Jan 13, 2012 at 14:53
  • Instead, if you don't actually need a POSIX compatibility layer, I recommend you to get a native Windows compiler instead of using CygWin (MinGW or VC++ are the most used). Commented Jan 13, 2012 at 14:59
  • its working now...:) .....thank u all for ur help......
    – amritha
    Commented Jan 13, 2012 at 16:15

6 Answers 6


You need to add some " around your path, as it contains spaces :

cd "c:\Program files\internet explorer"


  • but now,when i give
    – amritha
    Commented Jan 13, 2012 at 14:53
  • $ g++ hello.cpp-o main i get the error g++: hello.cpp-o: No such file or directory g++: main: No such file or directory g++: no input files
    – amritha
    Commented Jan 13, 2012 at 14:54
  • You forgot a space between hello.cpp and -o. Commented Jan 13, 2012 at 14:56
  • i used space..... but i got the same error
    – amritha
    Commented Jan 13, 2012 at 15:06
  • try g++ hello.cpp -o test.exe
    – Michael
    Commented Jan 13, 2012 at 15:10

This has nothing to do with GCC or the g++ compiler. The problem is that the command prompt thinks that c:\program files\internet explorer is actually three arguments: "c:\program", "files\internet" and "explorer". You need to put it in quotes like this "c:\program files\internet explorer".


You have a space in your path ...

cd "c:\program files\internet explorer"

This is only tangentially C++, but cd "c:\program files\internet explorer".


bash uses backslashes as escapes, similar to C string literals. Try cd '/cygdrive/c/Program Files/Internet Explorer' since bash also doesn't quite understand drive letters, and will consider the spaces as argument separators without the quotes.


CygWin is a POSIX emulation layer, thus CygWin programs use POSIX-like paths, which do not have the concept of drive letters, but everything is under the / hierarchy. Long story short, to access Windows paths you have to refer to the path hierarchy under /cygdrive/. (see CygWin documentation)

Your c:\Program files\Internet Explorer will become /cygdrive/c/Program Files/Internet Explorer (naturally you'll have to add quotes, otherwise bash will interpret the space as an argument separator).

Edit: apparently the cd command does this mapping by itself; still, it's a thing to keep in mind that CygWin programs will actually see the POSIX path, not the Windows path.

On the other hand, I don't see why you should be using CygWin if you are only programming in standard C++: probably you don't need a POSIX emulation layer, but a native C++ compiler for Windows. You can use for example MinGW (the Windows port of gcc) or Visual C++ (whose Express Edition is available for free).

You must log in to answer this question.