Search code examples
qtmakefileqt-creatorqmakenmake

How to make Makefile generated by qmake on windows? (nmake and mingw-make)


OS: Windows 10, x64

I have a simple demo of qt console project, which simply print hello world. This project can be built and run correctly(with MSVC kit), but I want to separate the process.

First, I click "execute qmake" in the right-click menu on the project in Qt Creator, I got a make file in the release and debug directory

build-hello-Desktop_Qt_5_12_3_MSVC2017_64bit-Release\makefile

open cmd, cd to this directory, and then the story ends. If I use nmake, I got error C1083, which tell me can not find stdio.h If I use make on windows or mingw-make32, I still got an error missing separator.

I have 2 questions:

1.Can someone give a full instruction of how to make this makefile both with mingw-make32 and nmake?

2.The makefile generated by qmake looks very complex and illegible, not like those makefiles in tutorial. Is it just the same as a normal makefile, or it's special?

I search for a lot but still can get the clear solution so please help.

the Makefile looks like this:

#############################################################################
# Makefile for building: hello
# Generated by qmake (3.1) (Qt 5.12.3)
# Project:  ..\name\hello.pro
# Template: app
# Command: C:\Qt\Qt5.12.3\5.12.3\msvc2017_64\bin\qmake.exe -o Makefile ..\name\hello.pro -spec win32-msvc "CONFIG+=qtquickcompiler"
#############################################################################

MAKEFILE      = Makefile

EQ            = =

first: release
install: release-install
uninstall: release-uninstall
QMAKE         = C:\Qt\Qt5.12.3\5.12.3\msvc2017_64\bin\qmake.exe
DEL_FILE      = del
CHK_DIR_EXISTS= if not exist
MKDIR         = mkdir
COPY          = copy /y
COPY_FILE     = copy /y
COPY_DIR      = xcopy /s /q /y /i
INSTALL_FILE  = copy /y
INSTALL_PROGRAM = copy /y
INSTALL_DIR   = xcopy /s /q /y /i
QINSTALL      = C:\Qt\Qt5.12.3\5.12.3\msvc2017_64\bin\qmake.exe -install qinstall
QINSTALL_PROGRAM = C:\Qt\Qt5.12.3\5.12.3\msvc2017_64\bin\qmake.exe -install qinstall -exe
DEL_FILE      = del
SYMLINK       = $(QMAKE) -install ln -f -s
DEL_DIR       = rmdir
MOVE          = move
SUBTARGETS    =  \
        release \
        debug

Solution

  • full instruction of how to make this makefile with nmake

    run visual studio command prompt and then run nmake inside it rather than run nmake in common cmd, because vs command prompt has already set the specific environment variables such as the path of includes and c++ standard library, whichout which cl.exe and link.exe can not work.

    This is the reason exacly why can not find stdio.h.