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:
所以我正在尝试运行我用C语言编写的第一个hello world编程。我在eclipse中编译它并且没有错误,但是当我尝试运行它时,我得到:
"This application has failed to start because cygwin1.dll was not found."
“此应用程序无法启动,因为找不到cygwin1.dll。”
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:
我发现这篇文章似乎表明我应该将它添加到Windows PATH,我用它来做到这一点。所以现在我的环境变量中的“Path”已经附加了“; C:\ cygwin \ bin \ cygwin1.dll”。仍然没有工作。任何人都知道我可能做错了什么?我的“程序”看起来像这样:
#include <stdio.h>
main()
{
printf("hello, world\n");
}
3 个解决方案
#1
17
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.
PATH环境变量需要包含包含cygwin1.dll的目录,而不是cygwin1.dll本身的路径。所以只需确保PATH中包含字符串“C:\ cygwin \ bin”。
#2
15
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.)
顺便说一下,我恳请你不要盲目地将包含cygwin1.dll的目录添加到系统PATH中。顺序搜索路径。如果你碰巧在路径中有较旧或较新版本的Cygwin运行时,那么与cygwin1.dll相关联的其他程序可能会崩溃(除非你知道你正在寻找不同的DLL版本,否则找出发生的事情并非易事。 。)
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.
您应该做的是将cygwin1.dll(以及您的程序可能需要的其他Cygwin DLL)复制到保存二进制文件的目录中,然后创建一个空的(零字节长度)文件,其名称与您的可执行文件相同,但附加了.local,即,如果您的可执行文件是mytest.exe,则创建名为mytest.exe.local的文件。这将告诉PE加载器首先在保存二进制文件的同一目录中查找所需的DLL,从而避免以后遇到很多麻烦。
#3
0
I had the same problem... Adam Rosenfield's answer solved it nice. At my Computer the path needs to be "C:\cygwin64\bin"
我遇到了同样的问题...... Adam Rosenfield的回答很好解决了。在我的电脑上,路径必须是“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.
我第一次没有认识到我的cygwin版本是64位......但是很清楚,路径变量中的这些微小差异决定了它是否可行 - 或者不行。
#1
17
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.
PATH环境变量需要包含包含cygwin1.dll的目录,而不是cygwin1.dll本身的路径。所以只需确保PATH中包含字符串“C:\ cygwin \ bin”。
#2
15
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.)
顺便说一下,我恳请你不要盲目地将包含cygwin1.dll的目录添加到系统PATH中。顺序搜索路径。如果你碰巧在路径中有较旧或较新版本的Cygwin运行时,那么与cygwin1.dll相关联的其他程序可能会崩溃(除非你知道你正在寻找不同的DLL版本,否则找出发生的事情并非易事。 。)
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.
您应该做的是将cygwin1.dll(以及您的程序可能需要的其他Cygwin DLL)复制到保存二进制文件的目录中,然后创建一个空的(零字节长度)文件,其名称与您的可执行文件相同,但附加了.local,即,如果您的可执行文件是mytest.exe,则创建名为mytest.exe.local的文件。这将告诉PE加载器首先在保存二进制文件的同一目录中查找所需的DLL,从而避免以后遇到很多麻烦。
#3
0
I had the same problem... Adam Rosenfield's answer solved it nice. At my Computer the path needs to be "C:\cygwin64\bin"
我遇到了同样的问题...... Adam Rosenfield的回答很好解决了。在我的电脑上,路径必须是“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.
我第一次没有认识到我的cygwin版本是64位......但是很清楚,路径变量中的这些微小差异决定了它是否可行 - 或者不行。