Reputation: 6765
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.
Upvotes: 0
Views: 1772
Reputation: 341
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.
Upvotes: 1
Reputation: 2485
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".
Upvotes: 1
Reputation: 186
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.
Upvotes: 2
Reputation: 56129
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.
Upvotes: 0