← 返回命令列表

Linux command

qmake 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Generate Makefile from .pro file

qmake [project.pro]

Generate for debug build

qmake CONFIG+=debug [project.pro]

Generate for release build

qmake CONFIG+=release [project.pro]

Generate Xcode project

qmake -spec macx-xcode [project.pro]

Generate Visual Studio project

qmake -spec win32-msvc [project.pro] -tp vc

Create new .pro file

qmake -project

Show Qt configuration

qmake -query

说明

qmake generates build system files for Qt projects. It reads .pro project files and produces Makefiles or IDE project files. Project files (.pro) declare sources, headers, libraries, and build options. The qmake syntax is declarative, simpler than hand-written Makefiles. Configuration options control build type, features, and platform specifics. Debug and release builds use different compiler flags. Platform specifications target different build systems. Each platform has makespec files defining compiler, linker, and platform settings. IDE integration generates native project files. Xcode projects on macOS, Visual Studio solutions on Windows. Qt modules are linked using QT variable. Network, SQL, widgets, and other modules are added as needed.

参数

-o _file_
Write output to file. If not specified, qmake chooses a suitable name.
-spec _spec_
Use spec as path to platform and compiler information, overriding QMAKESPEC.
-makefile
Generate Makefile (default mode).
-project
Generate a .pro project file from source files in the current directory.
-tp _type_
Target project type (e.g., vc for Visual Studio).
-query _var_
Query Qt configuration variables. Without var, lists all values.
-set _var_ _value_
Set a persistent Qt configuration variable.
-unset _var_
Unset a persistent Qt configuration variable.
CONFIG+=_value_
Add configuration option (e.g., debug, release, static).
-r, --recursive
Process subdirectories recursively.
-after
Process command line assignments after project file.
-early
Process command line assignments before project file.
-t _template_
Override the TEMPLATE variable.
-d
Enable debug output. Multiple -d flags increase verbosity.
-v
Display version information.
-Wall, -Wnone, -Wparser, -Wlogic
Control qmake warning levels.
-cache _FILE_, -nocache
Use an alternative .qmake.cache file or skip it entirely.
-nodepend
Disable automatic dependency generation.
-help
Display help information (single-dash form is canonical).

FAQ

What is the qmake command used for?

qmake generates build system files for Qt projects. It reads .pro project files and produces Makefiles or IDE project files. Project files (.pro) declare sources, headers, libraries, and build options. The qmake syntax is declarative, simpler than hand-written Makefiles. Configuration options control build type, features, and platform specifics. Debug and release builds use different compiler flags. Platform specifications target different build systems. Each platform has makespec files defining compiler, linker, and platform settings. IDE integration generates native project files. Xcode projects on macOS, Visual Studio solutions on Windows. Qt modules are linked using QT variable. Network, SQL, widgets, and other modules are added as needed.

How do I run a basic qmake example?

Run `qmake [project.pro]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -o _file_ do in qmake?

Write output to file. If not specified, qmake chooses a suitable name.