2

The Idea
I've compiled a C++ exe using G++ on Cygwin, and I want to be able to get the output of that exe into my HTML via PHP. That is, let's say I have a C++ executable "test.exe" which outputs "Hello, World!" when run. Then logically, I should be able to do

<?=exec("./test.exe")?>

To send the output of the test.exe file to the file.

The Issue
I'm testing this on a local WAMP server on Win7. Apparently, exec and system calls on Win7 WAMP go through the Windows command prompt, meaning it's running batch instead of bash. For some reason, batch doesn't like Cygwin-compiled executables, giving the error:

"The program can't start because cygwin1.dll is missing from your computer. Try reinstalling the program to fix this problem."

So, how can I make it so windows batch can execute cygwin-compiled files?

3 Answers 3

4

You could do a few things:

  1. You could compile your application with Visual Studio (I believe Microsoft provides a free version ... Visual Studio Express). This is the route I would personally take. You won't need to rely on the cygwin DLL's (unless you're compiling in some part of the cygwin install), and your executable would be much more portable across Windows systems.
  2. You could place the location of the cygwin1.dll into your system PATH environment variable. This has the advantage of future executables built using cygwin running successfully, but has the disadvantage that should you want to distribute your application, other users wouldn't be able to run it out of the box.
  3. You could copy cygwin1.dll from the /bin directory of your cygwin installation into the same folder as your executable. This is portable (among Windows systems ... to some extent), but has the disadvantage that it might violate the Cygwin license (not having read the license, I'm not sure). I would only recommend this route for testing purposes.
1
  • Answered for being the most thorough, but thank you to everyone who answered. It really was just as easy as copying 3 DLLs! I'll try your other solutions soon.
    – Will
    Jan 17, 2012 at 2:59
3

"The program can't start because cygwin1.dll is missing from your computer. Try reinstalling the program to fix this problem."

Well the error message here is pretty clear. Executables compiled with Cygwin need cygwin1.dll to run. The easy way is to just copy that cygwin1.dll into the same locate as your executable so it can find it.

If you're not too crazy about that dependency you can try building your hello world with MinGW instead which doesn't have such dependencies.

2

Copy cygwin1.dll into the directory containing test.exe

See The program can't start because cygwin1.dll is missing... in Eclipse CDT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.