Reputation: 322
I'm trying to build a cross-compiler with Qt 5.4.1 to generate Raspberry Pi executables from a Windows 8.1 64-bit machine.
I'm using mingw64 and a gcc 4.9 cross-compiler for the Pi on the Windows machine and I am using the Qt 5.4.1 source. PATH points to the mingw64 binaries, the gcc 4.9 cross-compiler binaries, perl binaries, and %windir%\system32.
I use the following command to build the Qt cross-compiler:
configure.bat -platform win32-g++ -opengl es2 -device linux-rasp-pi-g++ \
-device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot \dev\qtxc\sysroot \
-opensource -confirm-license -release -make libs -prefix d:\dev\qtxc \
-platform win32-g++ -xplatform linux-arm-gnueabi-g++
Everything works fine until the very end when I get a few error messages containing Unix commands (again, I'm on a Windows machine in a Windows command prompt):
Running configuration tests...
process_begin: CreateProcess(NULL, rm -f arch.obj, ...) failed.
make (e=2): The file cannot be found
(...)
Then when I look at the generated Makefile, I can see that it erroneously defines Unix commands instead of Windows commands:
# Makefile for building: qt
# Generated by qmake (3.0) (Qt 5.4.1)
# Project: qt.pro
# Template: subdirs
# Command: D:\dev\qtxc\qtbase\bin\qmake -o Makefile qt.pro
MAKEFILE = Makefile
first: make_first
QMAKE = D:\dev\qtxc\qtbase\bin\qmake
DEL_FILE = rm -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
COPY = cp -f
COPY_FILE = cp -f
COPY_DIR = cp -f -R
(...)
Then, of course, when I try to run mingw32-make
as instructed in the output from the configure
command, I get error messages related to the Unix commands that don't exist in Windows:
module-qtbase-qmake_all: FORCE
@test -d qtbase\ || mkdir -p qtbase\
cd qtbase\ && $(QMAKE) D:\dev\qtxc\qtbase\qtbase.pro -o Makefile
cd qtbase\ && $(MAKE) -f Makefile qmake_all
(@test
doesn't work in Windows, of course).
I have tried modifying the qtbase\mkspecs\win32-g++\qmake.conf
file to remove the Unix conditional definitions (seems like nonsense to have those in the win32 file anyway), forcing the definition of QMAKE_SH
or QMAKE_OS_WIN32
, to no avail.
Any suggestions?
Upvotes: 2
Views: 3188
Reputation: 138
I had the very same problem myself while setting up a Gitlab-CI runner to compile a Qt project on windows.
Using the -d
(debug) option on qmake (see Running qmake) I discovered that qmake looks for sh
in PATH and then determines which command set to use by setting QMAKE_SH.
If you seach for QMAKE_SH
in the debug output of qmake bottom up, you should find the line where qmake makes the above described decision. In case sh
was found, searching further up will take you to the line where the actual path to sh
is printed out.
Mine was found in the path to Git for Windows (<path to git>\bin
), since there is a 'sh.exe' in the bin folder next to git.exe.
I found two solutions for my particular case:
<path to git>\usr\bin
.SET PATH=%PATH:<path to remove>;=%
to the command line.Upvotes: 3