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

前端 未结 4 873
忘掉有多难
忘掉有多难 2021-01-05 00:50

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 fail

相关标签:
4条回答
  • 2021-01-05 01:39

    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.

    0 讨论(0)
  • 2021-01-05 01:49

    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.

    0 讨论(0)
  • 2021-01-05 01:52

    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.

    0 讨论(0)
  • 2021-01-05 01:52

    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.)

    0 讨论(0)
提交回复
热议问题