How to call bash from Qt creator on windows 10 - qt-creator

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?

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.

Related

Jenkins on Windows 10 with Bash

I'm currently setting up a Jenkins server on Windows 10, in the hope of being able to make the build scripts more cross platform I was hoping to take advantage of the bash environment that is available in Windows 10.
I hoped this could be done just by setting the path to the shell in Jenkins to be the bash executable, however I've encountered some problems with trying to get this to work.
Firstly when I set the path to be C:\Windows\System32\bash.exe but Jenkins didn't seem to be able to see this path.
I assumed this was because Jenkins was running as 32-bit and changed the path to be C:\Windows\sysnative\bash.exe but when I try and use this I get the error
[workspace] $ C:\Windows\sysnative\bash.exe -xe C:\Users\Jenkins\AppData\Local\Temp\hudson4346151084156392102.sh
Error: 0x80070005
Build step 'Execute shell' marked build as failure
I think I'm poking around in the dark a bit so I didn't know if anyone had any experience of trying to use the bash shell on Windows 10 within Jenkins?
The error 0x80070005 usually appears during Windows Update or by specific applications, because of the .DLL files permission being denied. Look at your permissions and then try again.
You can run this on Windows in order to execute a bash shell script:
bash -c /mnt/c/Users/$LOGNAME/Downloads/abc.sh
Make sure that the script is executable (chmod +x)
(Only works on Windwos 10 with a linux subsystem installed)

Kicking off a WSL bash-based build from Visual Studio 2015

I recently started using the Windows Subsystem for Linux (WSL) to see if my Linux Makefile & arm-none-eabi-gcc based microcontroller project would build "natively" in Windows. To my surprise, the tool chain and Linux based development tools installed and worked perfectly on first go, without any modifications to the Makefile.
So that got me thinking to try doing all my code editing in Visual Studio using the IDE features while doing the actual build in the Linux & bash environment provided in WSL.
Unfortunately, when specifying a "Build Command Line" in the NMake options for my Visual Studio project, putting in "C:\Windows\System32\bash.exe build.sh" doesn't work because:
'C:\Windows\System32\bash.exe' is not recognized as an internal or external command,
operable program or batch file.
This is strange to me because I specified the full path and it couldn't find the WSL bash executable, and also attempting to add it as an "External Tool" doesn't seem to work because the executable doesn't show up in the selection window despite being able to see other executables in the same directory.
Some off topic opinion: If Microsoft can make Visual Studio and WSL work together seamlessly then I would likely switch from my Ubuntu virtual machine setup for a WSL based development environment.
Here's how you have to do it:
Nmake is not a 64-bit application, so when it tries to use Windows utilities and system32, WoW64 tricks it into looking in a different location.
The way you have to launch it from a 32-bit application is:
%windir%\sysnative\bash.exe
However, your command is also malformed. You will need to do it like this:
%windir%\sysnative\bash.exe -c "sh build.sh"
or maybe
%windir%\sysnative\bash.exe -c "./build.sh"
if DriveFS permissions allow execution.
otherwise it will attempt to execute build.sh as a command in your linux user's $PATH.
Source:
https://github.com/Microsoft/BashOnWindows/issues/870
This is what I have in my Build Command Line setting. It works fine.
start /WAIT %windir%\sysnative\bash.exe -c "cd /mnt/d/Projects/IoT/ESP8266/;./gen.sh -m DEBUG; read -n 1; exit;"

"Hello world" Fortran (gfortran) fails to run in Windows 8.1

I have the following code:
PROGRAM TEST
IMPLICIT NONE
PRINT *, "test"
END PROGRAM TEST
It is compiled successfully using this command:
C:/cygwin64/bin/x86_64-w64-mingw32-gfortran.exe test.f08 -o test.exe
When I run the program by double clicking it, it produces the error:
"The application was unable to start correctly (0xc000007b). Click OK to close the application."
The file libgfortran-3.dll is in the same folder as the executable. My environment is Windows 8.1 64-bit. Cygwin (Setup.exe version 2.850 (64 bit)) is installed to C:\cyginw64. All defaults packages were installed, along with all "Base" and "Devel" packages. My system PATH environment variable includes C:\cygwin64\bin. Running the program from the Cygwin64 terminal produces no output.
What is causing this error? I have another, more complicated program that suffers from the same error.
Possibly related: why gfortran under cygwin can't compile correctly?
That error code is an NTSTATUS code, specifically STATUS_INVALID_IMAGE_FORMAT. Almost without fail that means you are trying to load a 32 bit module into a 64 bit process. Or vice versa. Use a dependency analysis tool to work out which module has the wrong bitness. For example Dependency Walker.

How to include PATH executable in visual studio post-build

I'm trying to run a web app build process from Visual Studio and I got trouble running my scripts as the executable from the PATH config aren't included in the runned scripts.
Is there a way I can make sure the script is executed in a normal command line process? Or is there a way I can load these executable so they're available in the post/pre build script?
I'm using ruby and node.js in the build process (managed via Grunt). I can get Grunt to run easily by specifying the full absolute path, but then it fails when it tries to access Ruby commands.
So I found a solution working for me, I just launch the command in the cmd.exe process like so:
start cmd /C myCommand
With grunt, the full command can be this if someone is wondering:
start cmd /C %USERPROFILE%\AppData\Roaming\npm\grunt.cmd release --no-color > grunt_output.txt

GAE Go Windows - "Cannot run program", "is not a valid Win32 application"

I've been trying to run a GAE Go project I developed on my Mac on my Windows machine with GoClipse after installing and configuring the appropriate SDKs and so forth. When attempting to run the project, I get this error:
Exception occurred executing command line. Cannot run program
"C:\GoogleAppEngine\dev_appserver.py" (in directory
"D:\Golang\workspace\Project\src\pkg"): CreateProcess
error=193, %1 is not a valid Win32 application
How can I fix that error in order to run my project?
While the below configuration works on the Mac as it has Python installed by default, Windows requires a different configuration.
On Mac the GoClipse External Tools Configuration would be:
Location: /GoogleAppEngine/dev_appserver.py
Working Directory: ${workspace_loc:/Project/src/pkg}
Arguments: .
The Windows configuration should look like:
Location: C:\Python27\Python.exe
Working Directory:
Arguments: C:\GoogleAppEngine\dev_appserver.py "${workspace_loc:/Project/src/pkg}"
Trying to run .py (Which IMO is a Python file?) wont work directly on windows. You will need to install Python and then pass the above filename to Python something like (I don't know Python so don't go by exact syntax, you might need to look around)
python "C:\GoogleAppEngine\dev_appserver.py
The reason it's working on Mac is because Python comes pre-installed on mac as cited here But on windows it doesn't. So you can install Python and add the Python's bin folder to path, and then run above script and it should run fine!

Resources