0

我在 Windows 10 64 位上安装了 Qt Creator 4.4.1。我也bash on ubuntu on windows安装了。我想bash从 Qt 创建者调用,以便通过创建自定义构建过程步骤在项目目录上执行一些 linux 命令,但不幸的是我收到以下错误:

16:21:50: Running steps for project myTest...
16:21:50: Could not start process "bash" foamExec
Error while building/deploying project myTest (kit: Desktop Qt 5.9.3 MinGW 32bit)
When executing step "Custom Process Step"
16:21:50: Elapsed time: 00:00.

我也尝试了以下步骤:

  • bash指定:的完整路径,C:\Windows\System32\bash.exe但它失败并出现相同的错误。
  • 调用cmd以执行包含以下代码的 .bat 脚本:bash -c "my command that I want to execute"但我也收到以下错误:

    ``16:30:31: Running steps for project myTest...
    16:30:31: Starting: "C:\WINDOWS\system32\cmd.exe" /c "bash -c 'foamExec wmake'"
    'bash' is not recognized as an internal or external command,
    operable program or batch file.
    16:30:31: The process "C:\WINDOWS\system32\cmd.exe" exited with code 1.
    Error while building/deploying project myTest (kit: Desktop Qt 5.9.3 MinGW 32bit)
    When executing step "Custom Process Step"``.
    

  • 我试图在 Qt 中从以下位置创建外部命令:Tools > External,但我总是得到同样的错误。
  • 我还尝试从 bash 终端运行 Qt creator:"/mnt/c/Qt/Qt5.9.3/Tools/QtCreator/bin/qtcreator.exe"Qt Creator 启动正常,但它再次无法识别bash命令。
  • . 你能解释一下为什么 Qt Creator 无法识别bash吗?

    4

    1 回答 1

    0

    这不是一个完整的答案,但也许有人会弄清楚其余的。

    “无法识别bash”部分是因为这个问题- 基本上,Qt 是一个 32 位应用程序,而 bash.exe 是一个 64 位应用程序,并且由于 Qt 的 cmd 是 32 位的,所以它找不到它。

    但是,解决此问题会引入不同的错误。我尝试了以下方法:

    • 直接运行 bash,使用“C:\Windows\sysnative\bash.exe”路径
    • 在 64 位 cmd.exe 中包装 bash(运行“C:\Windows\sysnative\cmd.exe /C bash”)
    • 在 32 位 cmd.exe 中包装 bash(运行“cmd /CC:\Windows\sysnative\bash.exe”)

    以上都不起作用,而是以“进程退出,代码 -1”失败。即使使用 64 位版本的 QtCreator 也会发生这种情况 - 似乎 WSL 有一些东西阻止它在 QtCreator 中运行。

    于 2018-05-21T13:00:22.650 回答