How to execute a file in Cygwin?

How can I execute a.exe using the Cygwin shell?

I created a C file in Eclipse on Windows and then used Cygwin to navigate to the directory. I called gcc in the C source file and a.exe was created. I would like to run a.exe .

+41
c gcc cygwin
Aug 30 '08 at 14:45
source share
9 answers

./a.exe at the command line

+68
Aug 30 '08 at 14:50
source share

you can just call by typing the file name. You may need to call. /a.exe, because the current directory is usually not in the path for security reasons.

+9
Aug 30 '08 at 14:51
source share

just enter. / a in shell

+6
Aug 30 '08 at 14:51
source share

To execute the file in the current directory, the following syntax is used: ./foo

As allain mentioned, ./a.exe is the right way to execute a.exe in the working directory using Cygwin.

Note. You can use the -o option to cc to specify your own output file name. An example of this might be: cc helloworld.c -o helloworld.exe .

+2
Aug 30 '08 at 14:58
source share

Thomas wrote:

Gcc doesn't seem to behave as described in the CC programming language

This is generally. For your program running on Windows, it must end with .exe, the "C programming language" was not written with Windows programmers. As you have seen, cygwin emulates many, but not all, of the features of the POSIX environment.

+2
Aug 30 '08 at 15:02
source share

gcc under cygwin does not generate a Linux executable like “ELF 32-bit LSB executable”, but it does generate a Windows executable like “PE32 executable for MS Windows”, which has a dependency on cygwin1.dll, so it needs to be run under the cygwin shell . If you need to run it under the dos prompt yourself, they should be in your Windows PATH. Cyberwin1.dll.

-AD.

+2
Nov 10 '10 at 11:16
source share

Apparently, gcc does not behave as described in the C programming language, which says that the cc helloworld.c command creates a file called a.out, which can be launched by entering a.out at the prompt.

Unix didn’t behave like this by default (so you can just write an executable name without ./in front) for a long time. It is called a.exe, because otherwise Windows will not execute it, since it gets file types from the extension.

+1
Aug 30 '08 at 15:08
source share

Just call him

 > a 

Make sure it is found (path).

-2
Aug 30 '08 at 14:51
source share

When you start working in Cygwin, you are in the "/ home / Administrator" zone, so add the a.exe file there.

Then at the command prompt:

cd a.exe

It will be read by Cygwin and you will be asked to install it.

-5
Feb 11 '15 at 11:26
source share



All Articles