sober
sober

Reputation:

Cygwin1.dll 'not found' when running a program written in C. How can I make Windows find it?

So I'm trying to run my first hello world prog written in C. I compiled it in eclipse and get no errors, but when I try to run it I get:

"This application has failed to start because cygwin1.dll was not found."

I found this post which seems to indicate I should add it to Windows PATH, and I used this to do that. So now "Path" in my environment variables has ";C:\cygwin\bin\cygwin1.dll" appended to the end. Still no worky. Anyone have a clue what I might be doing wrong? My 'program' just looks like this:

#include <stdio.h>

main()
{
    printf("hello, world\n");
}

Upvotes: 9

Views: 31092

Answers (4)

not2qubit
not2qubit

Reputation: 17077

Add: ;C\cygwin64\bin to the end of your Windows system PATH variable.

Also, to compile for use in CMD or PowerShell, you may need to use:

x86_64-w64-mingw32-g++.exe -static -std=c++11 prog_name.cc -o prog_name.exe

(This invokes the cross-compiler, if installed.)

Upvotes: 0

Martin Pfeffer
Martin Pfeffer

Reputation: 12637

I had the same problem... Adam Rosenfield's answer solved it nice. At my Computer the path needs to be "C:\cygwin64\bin"

First time I didn't recognized that my version of cygwin is the 64bit... But it's quiet clear that these little difference in the path-variable decides if it will work - or not.

Upvotes: 0

Mihai Limbășan
Mihai Limbășan

Reputation: 67836

By the way, I implore you not to blindly add a directory containing cygwin1.dll to the system PATH. The path is searched sequentially. If you happen to have older or newer versions of the Cygwin runtime in the path, other programs linked against cygwin1.dll might break horribly (and it's not trivial to figure out what happened unless you know that you're looking for a different DLL version.)

What you should do is copy cygwin1.dll (and other Cygwin DLLs your program might require) into the directory which holds your binary then create an empty (zero byte length) file with the same name as your executable but with .local appended, i.e., if your executable is mytest.exe, you create a file named mytest.exe.local . That will tell the PE loader to first look for required DLLs in the same directory that holds your binary, thus avoiding a lot of headache later on.

Upvotes: 15

Adam Rosenfield
Adam Rosenfield

Reputation: 400700

The PATH environment variable needs to include the directory containing cygwin1.dll, not the path to cygwin1.dll itself. So just make sure that PATH has the string "C:\cygwin\bin" in it.

Upvotes: 19

Related Questions