2008年11月28日星期五

Qt qmake Makefile设置

从Qt提供的许多现存的源程序中找到相关的.pro项目文件,它们是学习qmake 更多技巧的最佳范例。

Makefile -->用 make 来开发和编译程式的确很方便 --> Makefile可以像这样由\".pro\"文件生成 --> qmake -o Makefile hello.pro (使用qmake作为Qt库和Qt所提供的工具的主要连编工具)用qmake 和.pro 文件一起生成 Makefile
--> 只需要写.pro 文件来链接它不同的链接库等等... ...


We will use qmake to build the executable, so we need to write a .pro file:
以下英文简介来自qmake用户手册:
Declaring Other Libraries
If you are using other libraries in your project in addition to those supplied with Qt, you need to specify them in your project file.
The paths that qmake searches for libraries and the specific libraries to link against can be added to the list of values in the LIBS variable. The paths to the libraries themselves can be given, or the familiar Unix-style notation for specifying libraries and paths can be used if preferred.
For example, the following lines show how a library can be specified:
LIBS += -L/usr/local/lib -lmath
The paths containing header files can also be specified in a similar way using the INCLUDEPATH variable.
For example, it is possible to add several paths to be searched for header files:
INCLUDEPATH = c:/msdev/include d:/stl/include


qmake 使用储存在项目(.pro)文件中的信息来决定Makefile文件中该生成什么,简单的说,所谓的设置配置的信息,就是在项目(.pro)文件中设定。 一个基本的项目文件包含关于应用程序的信息,比如,编译应用程序需要哪些文件,并且使用哪些配置设置。 这里是一个简单的示例项目文件:
SOURCES = hello.cpp
HEADERS = hello.h
CONFIG += qt warn_on release
Makefile可以设定使得 Qt Program可以被编译和链接(linken)。
例如:
win32:LIBS = $(QTDIR)/lib/qt-mt230nc.lib \ $(QTDIR)/lib/qtmain.lib
或:
win32:LIBS += C:/DXSDK/Lib/amstrmid.lib \
C:/DXSDK/Lib/d3d8.lib \
C:/DXSDK/Lib/d3d9.lib
不要忘了:路径中是用 / 相连!!.lib之间用 \ 相隔。
进阶阅读:如何用qmake快速生成makefile

没有评论: