Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Jan 13 '12 at 21:54

This question came from our site for professional and enthusiast programmers.

I recommend you install cygwin to C:\Cygwin (or some other directory without spaces). See for information about Windows paths – larsm Jan 13 '12 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). – Matteo Italia Jan 13 '12 at 14:59
its working now...:) .....thank u all for ur help...... – amritha Jan 13 '12 at 16:15
up vote 2 down vote accepted

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

cd "c:\Program files\internet explorer"


share|improve this answer worked... – amritha Jan 13 '12 at 14:53
but now,when i give – amritha Jan 13 '12 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 Jan 13 '12 at 14:54
You forgot a space between hello.cpp and -o. – Matteo Italia Jan 13 '12 at 14:56
i used space..... but i got the same error – amritha Jan 13 '12 at 15:06

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".

share|improve this answer

You have a space in your path ...

cd "c:\program files\internet explorer"
share|improve this answer

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

share|improve this answer

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.

share|improve this answer

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).

share|improve this answer

You must log in to answer this question.