Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

[Prev: Installing qmake] [Home] [Next: qmake Concepts]

The 10 minute guide to using qmake

Creating a project file

In order to use qmake to generate a makefile for your application you need to have a project (.pro) file. A basic project file contains information about your application such as which files are needed to compile it and basic configuration settings for the application.

A simple project file will look something like the following.

	SOURCES = hello.cpp
	HEADERS = hello.h
	CONFIG += qt warn_on release
	TARGET = hello

We'll go through this line by line briefly for now, and later on in the manual we will go into more detail about the available options.

	SOURCES = hello.cpp

This line specifies the source files for your application, in this case we only have one hello.cpp. If you have more than one in your project then you can either put it on the same line leaving a space between the source files

	SOURCES = hello.cpp main.cpp

Or you can put it on a separate line, if you do this then you need to put a after the last source file so it looks like

	SOURCES = hello.cpp \
		    main.cpp

Now we'll move onto the HEADERS line

	HEADERS = hello.h

This line specifies the header files for your application, this is used in the same way as the SOURCES line.

The next line is the CONFIG line

	CONFIG += qt warn_on release

The config line specifies the basic configuration of the application. For now, ignore the += part of the line, just ensure that you use this when you create your own project files.

The qt part of the CONFIG line tells qmake that the application is built using Qt. This means that qmake will link against the Qt libraries when linking and add in the neccesary include paths for compiling.

The warn_on part of the CONFIG line tells qmake that it should set the compiler flags for outputting warnings.

The release part of the CONFIG line tells qmake that the application is to be built as a release application. If you wish to build your application as a debug application then specify debug here instead of release.

The last line in the project file is the TARGET line

	TARGET = hello

The target line simply specifies what the name of the target should be for the application. You shouldn't put an extension here because qmake will do this for you.

When you create a project file, just save it as a .pro file, for example, we might save the project file in our example as hello.pro

Generating a makefile

When you have created your project file it is very easy to generate a makefile, all you need to do is go to where you have created your project file and type:

	qmake -o Makefile hello.pro 

And this will create a makefile for your application. If you want to create to a Visual Studio project file for your application then just put:

	qmake -t vcapp -o hello.dsp hello.pro

[Prev: Installing qmake] [Home] [Next: qmake Concepts]


Copyright © 2001 TrolltechTrademarks
Qt version 3.0.0-beta6