【问题标题】:Eclipse CDT clean fails on Windows: tries to run rm -rfEclipse CDT clean 在 Windows 上失败:尝试运行 rm -rf
【发布时间】:2013-07-31 14:48:18
【问题描述】:

我在 Windows 7 上使用带有 CDT 的 Juno。 当我尝试使用 MinGW 提供的内部构建器或 make 清理项目时,Eclipse 运行 *X 命令 rm -rf 并且清理操作失败。

从控制台使用外部构建器(mingw32-make)记录:

18:08:07 **** Clean-only build of configuration Debug for project threads_example ****
mingw32-make clean 
rm -rf  ./main.o  ./main.d  threads_example
process_begin: CreateProcess(NULL, rm -rf ./main.o ./main.d threads_example, ...) failed.
make (e=2): The system cannot find the file specified.

mingw32-make: [clean] Error 2 (ignored)
' '

18:08:07 Build Finished (took 137ms)

使用内部构建器记录:

10:39:35 **** Clean-only build of configuration Debug for project threads_example ****
rm -rf threads_example main.o main.d 
Cannot run program "rm": Launching failed

Error: Program "rm" not found in PATH
PATH=[C:\CS_powerpc\bin;C:/Program Files (x86)/Java/jre7/bin/client;C:/Program Files (x86)/Java    /jre7/bin;C:/Program Files (x86)/Java/jre7/lib/i386;C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;C:\Program Files (x86)\Roxio\OEM\AudioCore\;C:\siriusSDK\CS_i686\bin;c:\siriusSDK\CS_powerpc\bin;C:\siriusSDK\MinGW\msys\1.0\bin;C:\MinGW\bin;;C:\work\eclipse]


10:39:35 Build Finished (took 41ms)

10:39:35 **** Clean-only build of configuration Debug for project threads_example ****

10:39:35 Build Finished (took 46ms)

【问题讨论】:

  • 看起来 Eclipse + CDT 需要类似 UNIX 的命令才能按需要工作。我解决了在 Windows 上安装 GNU coreutils 5.3.0

标签: windows eclipse eclipse-cdt


【解决方案1】:

原来 .cproject 文件 xml 中有一个属性控制 clean 命令。

查找配置标记,并将cleanCommand 属性设置为您想要的。我已将其设置为 rm -rf 并使用 gnuutils 来支持 windows 上的命令。
您可以将命令更改为任何内容。

<configuration artifactExtension="so" artifactName="MyProject" ... cleanCommand="rm -rf" ...>

【讨论】:

  • 我创建了一个 Windows 配置,其中 (.cproject) 我将 rm 替换为 del /S .。有趣的是,CDT 控制台显示“无法运行程序 'del'...”,但删除仍然有效。
【解决方案2】:

最好的解决办法是安装GnuUtils/coreutils并将安装目录(C:\ProgramFiles\GnuWin32\bin)添加到你的windows路径,然后重启eclipse。

Eclipse 现在应该执行 rm-rf...

如果它仍然不起作用,只需重新启动 Windows(在 Windows 内存中设置路径)并再次检查您的路径以确保它具有 \GnuWin32\bin 。最后启动eclipse。

【讨论】:

  • CoreUtils for Windows 不仅为 Windows 系统上的本地 Linux 用户提供了 rm,还提供了许多其他 GNU 实用程序。它确实是一个非常好的解决方案。
【解决方案3】:

我找到了一个对我有用的解决方法: 如果您查看托管的 make makefile,您可以找到一行“RM := ...” 在该行之后有一行“-include ../makefile.defs”在我的情况下不存在。

如果您创建此文件,您可以将“RM := ...”宏重新定义为您想要的任何内容。

例如: RM := 删除

在这种情况下,自动构建过程将使用您的定义来删除文件和文件夹,而不是 eclipse 的预定义定义。

【讨论】:

    【解决方案4】:

    我遇到此错误是因为我在 Project->properties->C/C++ Build->Environment

    下的 MSYS_HOME 中有错字

    【讨论】:

      【解决方案5】:

      一个简单的解决方案是安装Git for Windows 并在安装选项中为cmd.exe 启用类Unix 命令。那么rm -rf就会被支持。

      【讨论】:

        猜你喜欢
        • 2011-02-28
        • 1970-01-01
        • 2021-10-30
        • 2012-11-16
        • 1970-01-01
        • 2010-09-11
        • 2021-04-09
        • 2015-01-09
        • 1970-01-01
        相关资源
        最近更新 更多