如何在Windows 10上从Qt创建者调用bash

时间:2018-04-19 15:38:49

标签: qt-creator bash-on-windows

我在Windows 10 64位上安装了Qt Creator 4.4.1。我还安装了bash on ubuntu on windows。我想从Qt创建者调用bash,以便通过创建自定义构建过程步骤在项目目录上执行一些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.

我也尝试了以下步骤:

  • 指定bashC:\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中创建外部命令:工具> 外部,但我总是遇到同样的错误。
  • 我还尝试从bash终端运行Qt创建者:"/mnt/c/Qt/Qt5.9.3/Tools/QtCreator/bin/qtcreator.exe" Qt Creator启动正常,但它又不识别bash命令。
  • 。 你能解释一下为什么Qt Creator无法识别bash吗?

    1 个答案:

    答案 0 :(得分:0)

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

    “bash not recognized”部分是因为this issue - 基本上,Qt是一个32位应用程序,而bash.exe是一个64位应用程序,而且由于Qt的cmd是32位,它找不到它。

    但是,解决这个问题会引入不同的错误。我尝试了以下内容:

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

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