Qt 在命令行中使用 "mingw32-make" 并出现 .exe 文件生成错误
Qt using "mingw32-make" in command line with .exe file generation error
到目前为止,我在命令行中使用了qmake -project
和qmake
配置.pro文件,Makefile.Debug和Makefile.Release已经解决了。但是当我尝试在命令行中使用 mingw32-make
为我的项目生成 .exe 时发生错误。
错误暗示行:
64 ****missing separator ...Stop
但在这种情况下,我已经为 mingw32-make.exe
和 qmake.exe
设置了所有环境变量。
有人说我应该在错误发生的地方makefile.release中添加一个Tab而不是space(错误的地方只有一个“<<”),但是当我发生其他错误时做出改变。而且我认为由于 Makefile 都是由 qmake
命令自动生成的,所以也许这不是真正的问题......
这是错误信息和 Makefile.Release 文件的一部分以供参考
:
Setting up environment for Qt usage...
Remember to call vcvarsall.bat to complete environment setup!
D:\qt5.10.9.2\msvc2017_64>cd D:\qtProgramme\helloworld
D:\qtProgramme\helloworld>mingw32-make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'D:/qtProgramme/helloworld'
Makefile.Release:64: *** missing separator. Stop.
mingw32-make[1]: Leaving directory 'D:/qtProgramme/helloworld'
Makefile:36: recipe for target 'release' failed
mingw32-make: *** [release] Error 2
D:\qtProgramme\helloworld>
这里是 Makefile.Release:
#############################################################################
# Makefile for building: helloworld
# Generated by qmake (3.1) (Qt 5.9.2)
# Project: helloworld.pro
# Template: app
#############################################################################
MAKEFILE = Makefile.Release
####### Compiler, tools and options
CC = cl
CXX = cl
DEFINES = -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG
CFLAGS = -nologo -Zc:wchar_t -FS -Zc:strictStrings -O2 -MD -W3 -w44456 -w44457 -w44458 $(DEFINES)
CXXFLAGS = -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc $(DEFINES)
INCPATH = -I. -I. -I..\..\qt5.10.9.2\msvc2017_64\include -I..\..\qt5.10.9.2\msvc2017_64\include\QtWidgets -I..\..\qt5.10.9.2\msvc2017_64\include\QtGui -I..\..\qt5.10.9.2\msvc2017_64\include\QtANGLE -I..\..\qt5.10.9.2\msvc2017_64\include\QtCore -Irelease -I..\..\qt5.10.9.2\msvc2017_64\mkspecs\win32-msvc
LINKER = link
LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'"
LIBS = /LIBPATH:D:\qt5.10.9.2\msvc2017_64\lib D:\qt5.10.9.2\msvc2017_64\lib\qtmain.lib /LIBPATH:C:\utils\my_sql\my_sql\lib /LIBPATH:C:\utils\postgresql\pgsql\lib shell32.lib D:\qt5.10.9.2\msvc2017_64\lib\Qt5Widgets.lib D:\qt5.10.9.2\msvc2017_64\lib\Qt5Gui.lib D:\qt5.10.9.2\msvc2017_64\lib\Qt5Core.lib
QMAKE = D:\qt5.10.9.2\msvc2017_64\bin\qmake.exe
IDC = idc
IDL = midl /NOLOGO
ZIP = zip -r -9
DEF_FILE =
RES_FILE =
COPY = copy /y
SED = $(QMAKE) -install sed
COPY_FILE = copy /y
COPY_DIR = xcopy /s /q /y /i
DEL_FILE = del
DEL_DIR = rmdir
MOVE = move
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
INSTALL_FILE = copy /y
INSTALL_PROGRAM = copy /y
INSTALL_DIR = xcopy /s /q /y /i
QINSTALL = D:\qt5.10.9.2\msvc2017_64\bin\qmake.exe -install qinstall
QINSTALL_PROGRAM = D:\qt5.10.9.2\msvc2017_64\bin\qmake.exe -install qinstall -exe
####### Output directory
OBJECTS_DIR = release
####### Files
SOURCES = main.cpp
OBJECTS = release\main.obj
DIST = main.cpp
QMAKE_TARGET = helloworld
DESTDIR = release\ #avoid trailing-slash linebreak
TARGET = helloworld.exe
DESTDIR_TARGET = release\helloworld.exe
####### Implicit rules
.SUFFIXES: .c .cpp .cc .cxx
{.}.cpp{release\}.obj::
$(CXX) -c $(CXXFLAGS) $(INCPATH) -Forelease\ @<<
$<
<<
{.}.cc{release\}.obj::
$(CXX) -c $(CXXFLAGS) $(INCPATH) -Forelease\ @<<
$<
<<
{.}.cxx{release\}.obj::
$(CXX) -c $(CXXFLAGS) $(INCPATH) -Forelease\ @<<
$<
<<
{.}.c{release\}.obj::
$(CC) -c $(CFLAGS) $(INCPATH) -Forelease\ @<<
$<
<<
####### Build rules
first: all
all: Makefile.Release $(DESTDIR_TARGET)
$(DESTDIR_TARGET): $(OBJECTS)
$(LINKER) $(LFLAGS) /MANIFEST:embed /OUT:$(DESTDIR_TARGET) @<<
release\main.obj
$(LIBS)
<<
qmake: FORCE
@$(QMAKE) -o Makefile.Release helloworld.pro
qmake_all: FORCE
您正在使用 Qt 的 MSVC 版本。这可以通过安装路径(D:\qt5.10.9.2\msvc2017_64)和输出"Remember to call vcvarsall.bat to complete environment setup!".
推断出来
来自 Qt 的 MSVC 构建的 QMake 生成与 MSVC 兼容的 makefile(至少默认情况下)。
安装 Qt 的 MinGW 版本,您可以在您的项目中使用 MinGW 工具链。
到目前为止,我在命令行中使用了qmake -project
和qmake
配置.pro文件,Makefile.Debug和Makefile.Release已经解决了。但是当我尝试在命令行中使用 mingw32-make
为我的项目生成 .exe 时发生错误。
错误暗示行:
64 ****missing separator ...Stop
但在这种情况下,我已经为 mingw32-make.exe
和 qmake.exe
设置了所有环境变量。
有人说我应该在错误发生的地方makefile.release中添加一个Tab而不是space(错误的地方只有一个“<<”),但是当我发生其他错误时做出改变。而且我认为由于 Makefile 都是由 qmake
命令自动生成的,所以也许这不是真正的问题......
这是错误信息和 Makefile.Release 文件的一部分以供参考
:
Setting up environment for Qt usage...
Remember to call vcvarsall.bat to complete environment setup!
D:\qt5.10.9.2\msvc2017_64>cd D:\qtProgramme\helloworld
D:\qtProgramme\helloworld>mingw32-make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'D:/qtProgramme/helloworld'
Makefile.Release:64: *** missing separator. Stop.
mingw32-make[1]: Leaving directory 'D:/qtProgramme/helloworld'
Makefile:36: recipe for target 'release' failed
mingw32-make: *** [release] Error 2
D:\qtProgramme\helloworld>
这里是 Makefile.Release:
#############################################################################
# Makefile for building: helloworld
# Generated by qmake (3.1) (Qt 5.9.2)
# Project: helloworld.pro
# Template: app
#############################################################################
MAKEFILE = Makefile.Release
####### Compiler, tools and options
CC = cl
CXX = cl
DEFINES = -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG
CFLAGS = -nologo -Zc:wchar_t -FS -Zc:strictStrings -O2 -MD -W3 -w44456 -w44457 -w44458 $(DEFINES)
CXXFLAGS = -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc $(DEFINES)
INCPATH = -I. -I. -I..\..\qt5.10.9.2\msvc2017_64\include -I..\..\qt5.10.9.2\msvc2017_64\include\QtWidgets -I..\..\qt5.10.9.2\msvc2017_64\include\QtGui -I..\..\qt5.10.9.2\msvc2017_64\include\QtANGLE -I..\..\qt5.10.9.2\msvc2017_64\include\QtCore -Irelease -I..\..\qt5.10.9.2\msvc2017_64\mkspecs\win32-msvc
LINKER = link
LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'"
LIBS = /LIBPATH:D:\qt5.10.9.2\msvc2017_64\lib D:\qt5.10.9.2\msvc2017_64\lib\qtmain.lib /LIBPATH:C:\utils\my_sql\my_sql\lib /LIBPATH:C:\utils\postgresql\pgsql\lib shell32.lib D:\qt5.10.9.2\msvc2017_64\lib\Qt5Widgets.lib D:\qt5.10.9.2\msvc2017_64\lib\Qt5Gui.lib D:\qt5.10.9.2\msvc2017_64\lib\Qt5Core.lib
QMAKE = D:\qt5.10.9.2\msvc2017_64\bin\qmake.exe
IDC = idc
IDL = midl /NOLOGO
ZIP = zip -r -9
DEF_FILE =
RES_FILE =
COPY = copy /y
SED = $(QMAKE) -install sed
COPY_FILE = copy /y
COPY_DIR = xcopy /s /q /y /i
DEL_FILE = del
DEL_DIR = rmdir
MOVE = move
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
INSTALL_FILE = copy /y
INSTALL_PROGRAM = copy /y
INSTALL_DIR = xcopy /s /q /y /i
QINSTALL = D:\qt5.10.9.2\msvc2017_64\bin\qmake.exe -install qinstall
QINSTALL_PROGRAM = D:\qt5.10.9.2\msvc2017_64\bin\qmake.exe -install qinstall -exe
####### Output directory
OBJECTS_DIR = release
####### Files
SOURCES = main.cpp
OBJECTS = release\main.obj
DIST = main.cpp
QMAKE_TARGET = helloworld
DESTDIR = release\ #avoid trailing-slash linebreak
TARGET = helloworld.exe
DESTDIR_TARGET = release\helloworld.exe
####### Implicit rules
.SUFFIXES: .c .cpp .cc .cxx
{.}.cpp{release\}.obj::
$(CXX) -c $(CXXFLAGS) $(INCPATH) -Forelease\ @<<
$<
<<
{.}.cc{release\}.obj::
$(CXX) -c $(CXXFLAGS) $(INCPATH) -Forelease\ @<<
$<
<<
{.}.cxx{release\}.obj::
$(CXX) -c $(CXXFLAGS) $(INCPATH) -Forelease\ @<<
$<
<<
{.}.c{release\}.obj::
$(CC) -c $(CFLAGS) $(INCPATH) -Forelease\ @<<
$<
<<
####### Build rules
first: all
all: Makefile.Release $(DESTDIR_TARGET)
$(DESTDIR_TARGET): $(OBJECTS)
$(LINKER) $(LFLAGS) /MANIFEST:embed /OUT:$(DESTDIR_TARGET) @<<
release\main.obj
$(LIBS)
<<
qmake: FORCE
@$(QMAKE) -o Makefile.Release helloworld.pro
qmake_all: FORCE
您正在使用 Qt 的 MSVC 版本。这可以通过安装路径(D:\qt5.10.9.2\msvc2017_64)和输出"Remember to call vcvarsall.bat to complete environment setup!".
推断出来来自 Qt 的 MSVC 构建的 QMake 生成与 MSVC 兼容的 makefile(至少默认情况下)。
安装 Qt 的 MinGW 版本,您可以在您的项目中使用 MinGW 工具链。