+4  A: 

Look for (that is, cd to)

/cygdrive/c/

that will usually be your C:\


Also look at Using Cygwin, the Lifehacker introduction (June/2006) and, this biomed page at PhysioNet.

nik
+1  A: 

when you start in cygwin, you are in your $HOME, like in unix generally, which maps to c:/cygwin/home/$YOURNAME by default. So you could put everything there.

You can also access the c: drive from cygwin through /cygdrive/c/ (e.g. /cygdrive/c/Documents anb Settings/yourname/Desktop).

David Cournapeau
This solution is the one I used. I was able to put everything (from source control) in to my $HOME and it worked like a charm. It is even easy to get to. Thanks!
Frank V
+1  A: 

Windows path C:\src under cygwin becomes /cygdrive/c/src

devdimi
A: 

Compiling your C program using Cygwin

We will be using the gcc compiler on Cygwin to compile programs.

1) Launch Cygwin

2) Change to the directory you created for this class by typing

cd c:/windows/desktop

3) Compile the program by typing

gcc myProgram.c -o myProgram

the command gcc invokes the gcc compiler to compile your C program.

joe
A: 

You might be better off editing a file inside of cygwin shell. Normally it has default user directory when you start it up. You can edit a file from the shell doing something like "vi somefile.c" or "emacs somefile.c". That's assuming vi or emacs are installed in cygwin.

If you want to file on your desktop, you'll have to go to a path similar (on XP) to "/cygwindrive/c/Documents\ and\ Settings/Frank/Desktop" (If memory serves correctly). Just cd to that path, and run your command on the file.

DoxaLogos
A: 

Cygwin is very cool! You can compile programs from other systems (Linux, for example), and they will work. I'm talking communications programs, or web servers, even.

Here is one trick. If you are looking at your file in the Windows File Explorer, you can type "cd " in your bash windows, then drag from explorer's address bar into the cygwin window, and the full path will be copied! This works in the Windows command shell as well, by the way.

Also: While "cd /cygdrive/c" is the formal path, it will also accept "cd c:" as a shortcut. You may need to do this before you drag in the rest of the path.

The stdio.h file should be found automatically, as it would be on a conventional system.

gbarry
+2  A: 

If you are not comfortable with bash, you can continue to work in a standard windows command (i.e. DOS) shell.

For this to work you must add C:\cygwin\bin (or your local alternative) to the Windows PATH variable.

With this done, you may: 1) Open a command (DOS) shell 2) Change the directory to the location of your code (c:, then cd path\to\file) 3) gcc myProgram.c -o myProgram

As mentioned in nik's response, the "Using Cygwin" documentation is a great place to learn more.

Tim Henigan
A: 

Just to summarize, here are some commands that navigate to a directory and compile code using Cygwin and Windows Vista:

  1. Start a Cygwin shell.
  2. At the prompt, use cd to change to the appropriate directory:

    $ cd /cygdrive/c/Users/nate/Desktop

  3. Use ls to list the files in the directory:

    $ ls

    prog.c

  4. Use the gcc command to compile a file in this directory:

    $ gcc prog.c -o prog

  5. If you don't see any errors, you should be able to run the resulting program:

    $ ./prog

Update:

For the "Cygwin1.dll not found" error, I like Nik's answer. You might also check out this related post about cygwin1.dll not found, which suggests adding c:\cygwin\bin\ to your Windows PATH.

There are instructions on how to change the Windows PATH variable for Windows XP, and on Vista I think it's similar.

  1. Go to Control Panel -> System
  2. Select Advanced System Settings
  3. Click on the Advanced tab
  4. Click on Environment Variables
  5. Under System Variables, find the Path entry and click Edit
  6. Add c:\cygwin\bin to the list, making sure to separate it from any previous items with a semicolon
Nate Kohl
The program will give the error I Posted above.
Frank V
Does changing your path help, either in the shell or from the Windows control panel?
Nate Kohl
+7  A: 

Regarding your updated question about the missing cygwin1.dll.

From the Cygwin terminal check,

ls /usr/bin/cygwin1.dll

If it is not present (I doubt that), your installation is not properly done.

Then, check your path with,

echo $PATH

This will give : separated list of paths. It MUST contain /usr/bin. If you find that missing add it with,

export PATH=/usr/bin:$PATH

Finally,

  • I hope you are using Cygwin from the cygwin terminal (the little green+black icon installed with Cygwin), or MinTTY (if you installed that).
  • And, you have not moved the compiled EXE to a different machine which does not have Cygwin installed (if you do that, you will need to carry the cygwin1.dll to that machine -- keep it in the same folder as the compiled EXE).
nik
+3  A: 

Regarding the cygwin1.dll not found error, a solution I have used for at least 8 years is to add the Cygwin bin directories to the end of my %PATH% in My Computer -> Properties -> Advanced -> Environment Variables. I add them to the end of the path so in my normal work, they are searched last, minimizing the possibility of conflicts (in fact, I have had no problems with conflicts in all this time).

When you invoke the Cygwin Bash Shell, those directories get prepended to the %PATH% so everything works as intended in that environment as well.

When not running in Cygwin shell, my %PATH% is:

Path=c:\opt\perl\bin; \
     ...
     C:\opt\cygwin\bin; \
     C:\opt\cygwin\usr\bin; \
     C:\opt\cygwin\usr\local\bin;

This way, for example, ActiveState Perl's perl is found first when I am not in a Cygwin Shell, but the Cygwin perl is found when I am working in the Cygwin Shell.

Sinan Ünür
+1  A: 

If you just do gcc program.c -o program -mno-cygwin it will compile just fine and you won't need to add cygwin1.dll to your path and you can just go ahead and distribute your executable to a computer which doesn't have cygwin installed and it will still run. Hope this helps

HackTalk