gpt4 book ai didi

c++ - 添加 qmake 文件(.pro)时这些命令的含义是什么

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:26:29 35 4
gpt4 key购买 nike

总之,我想把申请类型改成win32 app ,然后,我在 .pro file 中使用了以下命令

CONFIG -=windows
QMAKE_LFLAGS += $$QMAKE_LFLAGS_WINDOWS

使用前面的命令后,应用程序可以正常工作。
但是问题是我不知道这些命令的每一个命令的含义是什么。

任何人都可以解释这些命令的每个命令吗?

最佳答案

让我们看看CONFIG -= windows

qmake 手册摘录:CONFIG variable

CONFIG

The CONFIG variable specifies project configuration and compiler options. The values will be recognized internally by qmake and have special meaning. They are as follows.

[...]

The following options define the application/library type:

windows - The target is a Win32 window application (app only). The proper include paths, compiler flags and libraries will automatically be added to the project.

console - The target is a Win32 console application (app only). The proper include paths, compiler flags and libraries will automatically be added to the project.

手册的另一段摘录:Operators

Operators

In many project files, the assignment (=) and append (+=) operators can be used to include all the information about a project. The typical pattern of use is to assign a list of values to a variable, and append more values depending on the result of various tests. Since qmake defines certain variables using default values, it is sometimes necessary to use the removal (-=) operator to filter out values that are not required.

The -= operator removes a value from the list of values in a variable:

DEFINES -= USE_MY_STUFF

上面的行从预处理器列表中删除了 USE_MY_STUFF 定义放在生成的 Makefile 中。

因此,对于 CONFIG -= windows,您将从变量 CONFIG 的值列表中删除值 windows。看起来 windows 是您平台上 CONFIG 的默认值之一,您需要删除该值。值 windows 定义您的目标是 Win32 窗口应用程序。通过删除它,您声明您不希望拥有 Win32 窗口应用程序。如果您的目标是 Win32 控制台应用程序,那么建议显式声明它:CONFIG += console

现在让我们看看 QMAKE_LFLAGS += $$QMAKE_LFLAGS_WINDOWS

手册摘录:QMAKE_LFLAGS

QMAKE_LFLAGS

This variable contains a general set of flags that are passed to the linker. If you need to change the flags used for a particular platform or type of project, use one of the specialized variables for that purpose instead of this variable.

[...]

QMAKE_LFLAGS_WINDOWS

This is used on Windows only.

This variable contains link flags when building Windows GUI projects (i.e. non-console applications). The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

这意味着如果您想更改标志,则应更改 QMAKE_LFLAGS_CONSOLEQMAKE_LFLAGS_WINDOWS。但是,您通过添加 QMAKE_LFLAGS_WINDOWS 的值直接更改了 QMAKE_LFLAGS,这很奇怪,因为它包含用于构建 Win32 窗口应用程序的链接标志,并且您声明了 CONFIG -= windows 您不希望拥有 Win32 窗口应用程序。

关于c++ - 添加 qmake 文件(.pro)时这些命令的含义是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18686207/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com