How do I execute a file in Cygwin?

后端 未结 9 1192
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-03 17:26

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 on

相关标签:
9条回答
  • 2021-02-03 18:02

    To execute a file in the current directory, the syntax to use is: ./foo

    As mentioned by allain, ./a.exe is the correct way to execute a.exe in the working directory using 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.

    0 讨论(0)
  • 2021-02-03 18:04

    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.

    -AD.

    0 讨论(0)
  • 2021-02-03 18:08

    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.

    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.

    0 讨论(0)
  • 2021-02-03 18:11

    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.

    0 讨论(0)
  • 2021-02-03 18:14

    Just call it

    > a
    

    Make sure it will be found (path).

    0 讨论(0)
  • 2021-02-03 18:18

    just type ./a in the shell

    0 讨论(0)
提交回复
热议问题