双击运行可执行文件

发布于 2024-12-21 12:02:58 字数 125 浏览 4 评论 0原文

我已经通过 cygwin 使用 gcc 用 c 语言编写并编译了一个程序,当我从命令行运行该程序时,一切正常;但是,当我双击可执行文件时,命令窗口会在屏幕上短暂闪烁,但没有任何反应。任何想法为什么会这样?我使用的是 Windows 7。

I have written and compiled a program in c using gcc through cygwin, and everything works fine when I run the program from the command line; however, when I double-click the executable file, the command window briefly flashes on the screen, but nothing happens. Any ideas why this could be? I am using Windows 7.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

孤独陪着我 2024-12-28 12:02:58

当执行为该环境编译的文件时,Cygwin 要求 cygwin.dll 位于 PATH 中。当您使用 cygwin 编译某些内容时,您正在为 cygwin 进行编译。

如果您打算构建程序,我建议您使用 MinGW。当您使用 mingw 编译某些内容时,您正在为 Windows 进行编译。

Cygwin requires cygwin.dll to be in the PATH when executing files compiled for that environment. When you compile something with cygwin you are compiling for cygwin.

I would recommend using MinGW instead, if you plan on building programs. When you compile something with mingw you are compiling for windows.

江城子 2024-12-28 12:02:58

例如,您有一个打印“Hello World!”的程序。到命令行。
它将打印“Hello World!”如果它是从 cmd 打开的,但如果您双击它,它会打印它并立即关闭窗口。

尝试使用 getch() 来阻止它。它将打印“按任意键继续”。

For example you have program that prints "Hello World!" to command line.
It will print "Hello World!" if it's opened from cmd, but if you double click on it, it print it and immediatly close the window.

Try getch() to prevent it. It will print "Press any key to continue".

想念有你 2024-12-28 12:02:58

当您在cygwin中编译程序时,它将与动态库cygwin.dll链接。如果该文件的位置不在您的 PATH 变量中,您的程序将根本无法在 cygwin 之外运行。因此,找到 cygwin.dll 并将该目录添加到系统 PATH 变量中。

When you compile programs inside cygwin, it will link them with dynamic library cygwin.dll. If this file's location is not in your PATH variable, your programs will not run at all outside of cygwin. So, locate cygwin.dll and add that directory to system PATH variable.

乖乖 2024-12-28 12:02:58

它是图形应用程序吗?如果没有,则它没有获取输入,因此它可能正在开始,看到 EOF(如果它检查输入),然后完成。完成后,终端窗口将自动关闭。

Is it a graphical application? If not, it's not getting input, so it's probably starting, seeing the EOF (if it checks input at all), then finishing. When it's finished, the terminal window is closed automatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文