我的计算机上安装 Eclipse for Java 已有几年了,并决定安装 CDT 并学习 C。我安装了 MinGW
和 Cygwin
以及当我制作新项目时,CDT 会检测并尝试使用它们。
我选择文件 > 新建 C++ 项目
,然后选择 Hello World C++ 项目
和 CygwinGCC
工具链。我将项目命名为“asdf”并点击工具栏中的“Build Debug”。编译器完成,没有错误。我点击“运行”,但什么也没发生。
手动浏览到项目目录并运行 asdf.exe 会出现错误:
“程序无法启动,因为您的计算机缺少 cygwin1.dll。请尝试重新安装程序来解决此问题。”
使用 MinGW 也会发生同样的情况,只是缺少不同的 dll。
我需要做什么才能获得可用的 .exe?
(我运行的是 Windows 7 x64 以及最新版本的 Eclipse 和 CDT。)
编辑: 编译器输出如下:
**** Build of configuration Debug for project asdf ****
make all
Building file: ../src/asdf.cpp
Invoking: Cygwin C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/asdf.d" -MT"src/asdf.d" -o"src/asdf.o" "../src/asdf.cpp"
cygwin warning:
MS-DOS style path detected: C:\Users\Shawn\Dropbox\eclipse\asdf\Debug
Preferred POSIX equivalent is: /cygdrive/c/Users/Shawn/Dropbox/eclipse/asdf/Debug
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Finished building: ../src/asdf.cpp
Building target: asdf.exe
Invoking: Cygwin C++ Linker
g++ -o"asdf.exe" ./src/asdf.o
Finished building target: asdf.exe
最佳答案
此错误消息意味着 Windows 无法找到“cygwin1.dll”。 Cygwin gcc 创建的程序依赖于此 DLL。该文件是 cygwin 的一部分,因此很可能位于 C:\cygwin\bin 中。要解决此问题,您只需将 C:\cygwin\bin (或可以找到 cygwin1.dll 的位置)添加到系统路径中即可。或者,您可以将 cygwin1.dll 复制到 Windows 目录中。
有一个名为DependencyWalker的好工具,您可以从http://www.dependencywalker.com下载。 。您可以使用它来检查可执行文件的依赖关系,因此,如果您检查生成的程序,它会告诉您缺少哪些依赖关系以及哪些依赖关系已解决。
关于eclipse - 程序无法启动,因为 Eclipse CDT 中缺少 cygwin1.dll...,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6752578/