How can I execute a.exe
using the Cygwin shell?
如何执行a。使用Cygwin shell吗?
I created a C file in Eclipse on Windows and then used Cygwin to navigate to the directory. I called gcc on the C source file and a.exe
was produced. I would like to run a.exe
.
我在Windows上的Eclipse中创建了一个C文件,然后使用Cygwin导航到目录。我在C源文件和a上调用了gcc。exe。我想去跑步。
9 个解决方案
#1
71
./a.exe at the prompt
,/。exe在提示符中
#2
9
you should just be able to call it by typing in the file name. You may have to call ./a.exe as the current directory is usually not on the path for security reasons.
只需输入文件名就可以调用它。你可能得打电话。由于安全原因,exe作为当前目录通常不在路径上。
#3
6
just type ./a in the shell
只需输入。/a
#4
2
To execute a file in the current directory, the syntax to use is: ./foo
要在当前目录中执行文件,需要使用的语法是:./foo
As mentioned by allain, ./a.exe
is the correct way to execute a.exe in the working directory using Cygwin.
正如allain所提到的。exe是执行a的正确方式。exe在工作目录中使用Cygwin。
Note: You may wish to use the -o
parameter to cc
to specify your own output filename. An example of this would be: cc helloworld.c -o helloworld.exe
.
注意:您可能希望将-o参数使用到cc来指定您自己的输出文件名。例如:cc helloworld。c - o helloworld.exe。
#5
2
Thomas wrote:
托马斯写道:
Apparently, gcc doesn't behave like the one described in The C Programming language
显然,gcc的行为不像C语言中描述的那样
It does in general. For your program to run on Windows it needs to end in .exe, "the C Programming language" was not written with Windows programmers in mind. As you've seen, cygwin emulates many, but not all, features of a POSIX environment.
它一般。要使程序在Windows上运行,它需要以.exe结尾,“C编程语言”并不是为Windows程序员编写的。如您所见,cygwin模拟了POSIX环境的许多(但不是全部)特性。
#6
2
gcc under cygwin does not generate a Linux executable output file of type " ELF 32-bit LSB executable," but it generates a windows executable of type "PE32 executable for MS Windows" which has a dependency on cygwin1.dll, so it needs to be run under cygwin shell. If u need to run it under dos prompt independently, they cygwin1.dll needs to be in your Windows PATH.
cygwin下的gcc不生成“ELF 32位LSB可执行文件”类型的Linux可执行输出文件,但是它生成的windows可执行文件类型为“PE32可执行的MS windows”,该文件依赖于cygwin1。dll,所以需要在cygwin shell下运行。如果你需要在dos提示符下独立运行,它们会cygwin1。dll需要位于Windows路径中。
-AD.
广告。
#7
1
Apparently, gcc doesn't behave like the one described in The C Programming language, where it says that the command cc helloworld.c produces a file called a.out which can be run by typing a.out on the prompt.
显然,gcc的行为不像C编程语言中描述的那样,它说命令cc helloworld。c生成一个名为a的文件。输出可通过输入a运行。在提示符。
A Unix hasn't behaved in that way by default (so you can just write the executable name without ./ at the front) in a long time. It's called a.exe, because else Windows won't execute it, as it gets file types from the extension.
Unix在默认情况下没有这样的行为(因此您可以在很长一段时间内不写./在前面)。这就是所谓的。exe,因为else Windows不会执行它,因为它从扩展中获取文件类型。
#8
-2
Just call it
就叫它
> a
Make sure it will be found (path).
确保找到它(路径)。
#9
-5
When you start in Cygwin you are in the "/home/Administrator" zone, so put your a.exe file there.
当你开始在Cygwin你是在“/家/管理员”区,所以把你的a。exe文件。
Then at the prompt run:
然后在提示符下运行:
cd a.exe
cd a.exe
It will be read in by Cygwin and you will be asked to install it.
它将被Cygwin读取,您将被要求安装它。
#1
71
./a.exe at the prompt
,/。exe在提示符中
#2
9
you should just be able to call it by typing in the file name. You may have to call ./a.exe as the current directory is usually not on the path for security reasons.
只需输入文件名就可以调用它。你可能得打电话。由于安全原因,exe作为当前目录通常不在路径上。
#3
6
just type ./a in the shell
只需输入。/a
#4
2
To execute a file in the current directory, the syntax to use is: ./foo
要在当前目录中执行文件,需要使用的语法是:./foo
As mentioned by allain, ./a.exe
is the correct way to execute a.exe in the working directory using Cygwin.
正如allain所提到的。exe是执行a的正确方式。exe在工作目录中使用Cygwin。
Note: You may wish to use the -o
parameter to cc
to specify your own output filename. An example of this would be: cc helloworld.c -o helloworld.exe
.
注意:您可能希望将-o参数使用到cc来指定您自己的输出文件名。例如:cc helloworld。c - o helloworld.exe。
#5
2
Thomas wrote:
托马斯写道:
Apparently, gcc doesn't behave like the one described in The C Programming language
显然,gcc的行为不像C语言中描述的那样
It does in general. For your program to run on Windows it needs to end in .exe, "the C Programming language" was not written with Windows programmers in mind. As you've seen, cygwin emulates many, but not all, features of a POSIX environment.
它一般。要使程序在Windows上运行,它需要以.exe结尾,“C编程语言”并不是为Windows程序员编写的。如您所见,cygwin模拟了POSIX环境的许多(但不是全部)特性。
#6
2
gcc under cygwin does not generate a Linux executable output file of type " ELF 32-bit LSB executable," but it generates a windows executable of type "PE32 executable for MS Windows" which has a dependency on cygwin1.dll, so it needs to be run under cygwin shell. If u need to run it under dos prompt independently, they cygwin1.dll needs to be in your Windows PATH.
cygwin下的gcc不生成“ELF 32位LSB可执行文件”类型的Linux可执行输出文件,但是它生成的windows可执行文件类型为“PE32可执行的MS windows”,该文件依赖于cygwin1。dll,所以需要在cygwin shell下运行。如果你需要在dos提示符下独立运行,它们会cygwin1。dll需要位于Windows路径中。
-AD.
广告。
#7
1
Apparently, gcc doesn't behave like the one described in The C Programming language, where it says that the command cc helloworld.c produces a file called a.out which can be run by typing a.out on the prompt.
显然,gcc的行为不像C编程语言中描述的那样,它说命令cc helloworld。c生成一个名为a的文件。输出可通过输入a运行。在提示符。
A Unix hasn't behaved in that way by default (so you can just write the executable name without ./ at the front) in a long time. It's called a.exe, because else Windows won't execute it, as it gets file types from the extension.
Unix在默认情况下没有这样的行为(因此您可以在很长一段时间内不写./在前面)。这就是所谓的。exe,因为else Windows不会执行它,因为它从扩展中获取文件类型。
#8
-2
Just call it
就叫它
> a
Make sure it will be found (path).
确保找到它(路径)。
#9
-5
When you start in Cygwin you are in the "/home/Administrator" zone, so put your a.exe file there.
当你开始在Cygwin你是在“/家/管理员”区,所以把你的a。exe文件。
Then at the prompt run:
然后在提示符下运行:
cd a.exe
cd a.exe
It will be read in by Cygwin and you will be asked to install it.
它将被Cygwin读取,您将被要求安装它。