为什么Qt使用自己的make工具qmake?

时间:2022-04-11 02:03:30

I just started using Qt and noticed that it uses its own make tool, qmake.

我刚开始使用Qt,注意到它使用自己的make工具qmake。

  • Why does Qt use its own make tool?
  • 为什么Qt使用自己的make工具?
  • Is there something special that prevents it from using a standard make tool?
  • 有什么特别的东西阻止它使用一个标准的制作工具吗?
  • Does qmake call the GCC C++ compiler?
  • qmake调用GCC c++编译器吗?

5 个解决方案

#1


53  

Qt uses qmake to transparently support Qt's various addons, including "moc, the meta-object compiler" (which provides signals & slots), "uic, the ui compiler" (which creates header files from .ui designer files), "rcc, the resource compiler" (which compiles resources).

Qt使用qmake透明地支持Qt的各种插件,包括“moc,元对象编译器”(提供信号和插槽)、“uic, ui编译器”(从.ui设计器文件创建头文件)、“rcc,资源编译器”(编译资源)。

There's nothing to stop you using any build system you want. however, it's a lot more work. For example, you need to run "moc" over every header file that contains a class that has signals or slots. In general it's not recommended, especially for someone who's just starting to use Qt.

没有什么可以阻止您使用任何您想要的构建系统。然而,这需要更多的工作。例如,您需要在包含有信号或插槽的类的每个头文件上运行“moc”。一般不推荐使用Qt,尤其是刚开始使用Qt的人。

QMake does not call g++/gcc directly. Instead, qmake creates native make files on your current platform. Under linux it creates standard GNU make files, under windows it can generate visual studio make files, under Mac OS X it can generate XCode project files. You then invoke your native build system (either GNU make, or MS NMake, or xcodebuild or whatever), which will call your native compiler (g++/gcc or whatever).

QMake不直接调用g+ /gcc。相反,qmake在当前平台上创建本地make文件。在linux下它创建标准GNU make文件,在windows下它可以生成visual studio make文件,在Mac OS X下它可以生成XCode项目文件。然后调用您的本机构建系统(GNU make, MS NMake, xcodebuild或其他),它将调用您的本机编译器(g++/gcc或其他)。

#2


8  

In my opinnion qmake is cool for simple projects (you can just qmake -project; qmake; make), but horrible and not documented enough for largish projects. Especially the configure functionality of qmake is a joke.

在我的opinnion qmake中,对于简单的项目来说,qmake是很酷的。qmake;但是对于较大的项目来说很可怕,而且没有足够的文档记录。特别是qmake的配置功能是一个笑话。

The best build systems I know are CMake and Waf (Python -based). In my own Qt-projects I use CMake to do the job. Just like KDE-guys :)

我所知道的最好的构建系统是CMake和Waf(基于Python的)。在我自己的qt项目中,我使用CMake来完成这项工作。就像KDE-guys:)

#3


5  

qmake is designed to be cross platform and flexible. It can compatible with Microsoft Visual Studio and Xcode.

qmake设计为跨平台和灵活。它可以兼容微软Visual Studio和Xcode。

You can find it all in the qmake Manual.

您可以在qmake手册中找到它。

qmake generates a Makefile based on the information in a project file. Project files are created by the developer, and are usually simple, but more sophisticated project files can be created for complex projects. qmake contains additional features to support development with Qt, automatically including build rules for moc and uic. qmake can also generate projects for Microsoft Visual studio without requiring the developer to change the project file.

qmake基于项目文件中的信息生成Makefile。项目文件由开发人员创建,通常很简单,但是可以为复杂的项目创建更复杂的项目文件。qmake包含了支持Qt开发的附加功能,包括moc和uic的构建规则。qmake还可以为Microsoft Visual studio生成项目,而不需要开发人员更改项目文件。

#4


5  

To support its signal/slot system Qt relies on a special preprocessor and compiler that generates intermediate objects that do much of the processing. They refer to this as the meta-object compiler or MOC.

为了支持它的信号/槽系统,Qt依赖于一个特殊的预处理器和编译器,它生成进行大量处理的中间对象。他们称之为元对象编译器或MOC。

See http://doc.trolltech.com/4.5/moc.html for details.

有关详细信息,请参阅http://doc.trolltech.com/4.5/moc.html。

The MOC (along with a couple of other intermediate tools) works in conjunction with qmake; which produces makefiles in your native format (VC++, g++, etc.) that build the intermediate files generated by the MOC as well as all of your source files into the final executable.

MOC(连同其他一些中间工具)与qmake一起工作;它以您的本机格式(vc++、g++等)生成makefile,这些文件将MOC生成的中间文件以及所有源文件构建为最终的可执行文件。

#5


3  

In order

为了

a) because it does lot behind the scenes for you

a)因为它在幕后为你做了很多

b) yes, see a)

b)是的,看到一个)

c) yes, it does call g++ (but can support other compilers if you have them)

c)是的,它确实调用g++(但是如果您有其他编译器,可以支持它们)

#1


53  

Qt uses qmake to transparently support Qt's various addons, including "moc, the meta-object compiler" (which provides signals & slots), "uic, the ui compiler" (which creates header files from .ui designer files), "rcc, the resource compiler" (which compiles resources).

Qt使用qmake透明地支持Qt的各种插件,包括“moc,元对象编译器”(提供信号和插槽)、“uic, ui编译器”(从.ui设计器文件创建头文件)、“rcc,资源编译器”(编译资源)。

There's nothing to stop you using any build system you want. however, it's a lot more work. For example, you need to run "moc" over every header file that contains a class that has signals or slots. In general it's not recommended, especially for someone who's just starting to use Qt.

没有什么可以阻止您使用任何您想要的构建系统。然而,这需要更多的工作。例如,您需要在包含有信号或插槽的类的每个头文件上运行“moc”。一般不推荐使用Qt,尤其是刚开始使用Qt的人。

QMake does not call g++/gcc directly. Instead, qmake creates native make files on your current platform. Under linux it creates standard GNU make files, under windows it can generate visual studio make files, under Mac OS X it can generate XCode project files. You then invoke your native build system (either GNU make, or MS NMake, or xcodebuild or whatever), which will call your native compiler (g++/gcc or whatever).

QMake不直接调用g+ /gcc。相反,qmake在当前平台上创建本地make文件。在linux下它创建标准GNU make文件,在windows下它可以生成visual studio make文件,在Mac OS X下它可以生成XCode项目文件。然后调用您的本机构建系统(GNU make, MS NMake, xcodebuild或其他),它将调用您的本机编译器(g++/gcc或其他)。

#2


8  

In my opinnion qmake is cool for simple projects (you can just qmake -project; qmake; make), but horrible and not documented enough for largish projects. Especially the configure functionality of qmake is a joke.

在我的opinnion qmake中,对于简单的项目来说,qmake是很酷的。qmake;但是对于较大的项目来说很可怕,而且没有足够的文档记录。特别是qmake的配置功能是一个笑话。

The best build systems I know are CMake and Waf (Python -based). In my own Qt-projects I use CMake to do the job. Just like KDE-guys :)

我所知道的最好的构建系统是CMake和Waf(基于Python的)。在我自己的qt项目中,我使用CMake来完成这项工作。就像KDE-guys:)

#3


5  

qmake is designed to be cross platform and flexible. It can compatible with Microsoft Visual Studio and Xcode.

qmake设计为跨平台和灵活。它可以兼容微软Visual Studio和Xcode。

You can find it all in the qmake Manual.

您可以在qmake手册中找到它。

qmake generates a Makefile based on the information in a project file. Project files are created by the developer, and are usually simple, but more sophisticated project files can be created for complex projects. qmake contains additional features to support development with Qt, automatically including build rules for moc and uic. qmake can also generate projects for Microsoft Visual studio without requiring the developer to change the project file.

qmake基于项目文件中的信息生成Makefile。项目文件由开发人员创建,通常很简单,但是可以为复杂的项目创建更复杂的项目文件。qmake包含了支持Qt开发的附加功能,包括moc和uic的构建规则。qmake还可以为Microsoft Visual studio生成项目,而不需要开发人员更改项目文件。

#4


5  

To support its signal/slot system Qt relies on a special preprocessor and compiler that generates intermediate objects that do much of the processing. They refer to this as the meta-object compiler or MOC.

为了支持它的信号/槽系统,Qt依赖于一个特殊的预处理器和编译器,它生成进行大量处理的中间对象。他们称之为元对象编译器或MOC。

See http://doc.trolltech.com/4.5/moc.html for details.

有关详细信息,请参阅http://doc.trolltech.com/4.5/moc.html。

The MOC (along with a couple of other intermediate tools) works in conjunction with qmake; which produces makefiles in your native format (VC++, g++, etc.) that build the intermediate files generated by the MOC as well as all of your source files into the final executable.

MOC(连同其他一些中间工具)与qmake一起工作;它以您的本机格式(vc++、g++等)生成makefile,这些文件将MOC生成的中间文件以及所有源文件构建为最终的可执行文件。

#5


3  

In order

为了

a) because it does lot behind the scenes for you

a)因为它在幕后为你做了很多

b) yes, see a)

b)是的,看到一个)

c) yes, it does call g++ (but can support other compilers if you have them)

c)是的,它确实调用g++(但是如果您有其他编译器,可以支持它们)