user9670403
user9670403

Reputation:

How to call bash from Qt creator on windows 10

I have Qt Creator 4.4.1 installed on Windows 10 64 bit. I have also bash on ubuntu on windows installed. I want to call bash from Qt creator in order to execute some linux commands on the project directory by creating a custom building process step but unfortunately I get the following error:

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.

I have also tried the following steps:

  • To specify the full path of bash: C:\Windows\System32\bash.exe but it fails with the same error.
  • To call cmd to execute a .bat script that contains the following code: bash -c "my command that I want to execute" but I get the following error as well:

    ``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"``.
    

  • I tried to create external commands in Qt from: Tools > External, but I get always the same error.
  • I tried also to run Qt creator from bash terminal: "/mnt/c/Qt/Qt5.9.3/Tools/QtCreator/bin/qtcreator.exe" Qt Creator starts fine but again it doesn't recognize bash command.
  • . Can you please explain me why Qt Creator cannot recognize bash?

    Upvotes: 0

    Views: 2307

    Answers (1)

    aburakov
    aburakov

    Reputation: 81

    This is not a complete answer, but maybe someone will figure out the rest.

    The "bash not recognized" part is because of this issue - basically, Qt is a 32-bit application, while bash.exe is a 64-bit application, and since Qt's cmd is 32-bit, it cannot find it.

    However, addressing this introduces a different error. I've tried the following:

    • Running bash directly, using "C:\Windows\sysnative\bash.exe" path
    • Wrapping bash in 64-bit cmd.exe (run "C:\Windows\sysnative\cmd.exe /C bash")
    • Wrapping bash in 32-bit cmd.exe (run "cmd /C C:\Windows\sysnative\bash.exe")

    Neither of the above work, instead failing with "The process exited with code -1". This happens even with a 64-bit version of QtCreator - it seems that there's something about WSL that prevents it from running inside QtCreator.

    Upvotes: 0

    Related Questions