views:

311

answers:

4

Hello,

I try to use Eclipse as an IDE for C programming. Hence, I installed cygwin successfully thereby getting gcc,gdb, and make tools. I'm able to execute C programs on cygwin, however I can't do that on Command prompt. I know, there must be a problem related to Path. But I added C:\Cygwin\bin;C:\Cygwin\usr\bin to the path. I double-checked the folders by bash command on Cygwin.

Nothing worked out yet. I've no idea about the next step. What I know is I can't use Eclipse in the present conditions.

Thanks in advance for valuable responses.

A: 
  1. Check your $path environment variable in cygwin
  2. Start Cygwin command line.
  3. Then type

    echo $path

  4. This will show you what paths to add.

Dragos Toader
A: 

I added C:\cygwin\bin to my PATH a long time ago, and it always worked correctly (and nothing else regarding Cygwin; C:\cygwin\usr\bin is certainly not needed, as that directory is empty... you only see /usr/bin from inside Cygwin as a mirror of /bin).

Check your Windows PATH from a cmd.exe prompt (a Windows Command Prompt) with a command such as:

C:\Documents and Settings\lapo.CYBERONE>echo %PATH%
C:\WINXP\system32;C:\WINXP;C:\WINXP\System32\Wbem;C:\cygwin\bin
(and some more stuff not of interest for this question)

If that indeed contains C:\cygwin\bin then something strange is happening: you can maybe try re-installing Cygwin but having some specific errors to verify could of course help the debug of the problem... when you do try to execute something Cygwin in cmd.exe what does it say? 'ls' is not recognized as an internal or external command, operable program or batch file. or nothing at all? And what's the errorlevel?

PS: this kind of question maybe would be more suited for superuser.com?

lapo
A: 

You can find the proper directory to add to your path by going into cygwin and using which and mount. For instance, locally these give me:

bash-3.2$ which gcc
/usr/bin/gcc
bash-3.2$ mount
C:\cygwin\bin on /usr/bin type system (binmode)
C:\cygwin\lib on /usr/lib type system (binmode)
C:\cygwin on / type system (binmode)

So I know that, to get gcc in my path, I need to add c:\cygwin\bin You should be able to do the same.

Conspicuous Compiler
A: 

The problem is that g++ is a link. Go to c:\cygwin\bin and type:

cmd /c dir g++*

do not type dir or ls, since this commands with execute cygwin commands and conversion will occur.

Cygwin can interpret this link as symlink, so if you type

bash -c g++

the compiler with run properly. Windows cannot do this. You can use:

readlink g++

to see where the link points to. It most probably points to C:\cygwin\bin\g++-3.exe . If you can use g++-3 then you are all set. If you need g++ to work then simply copy g++-3.exe to g++.exe, but this way you need to remember to update the file if you update g++-3.exe.

agsamek