[ fromfile: reusinglibs.xml id: reusinglibs ]
Many of our examples link with various libraries that we have supplied.
The one we use most frequently is called libutils.
You can download a tarball containing this library here.
Create a shell/environment variable CPPLIBS that points to a convenient (empty) directory and then unpack the utils tarball in that directory.
| Note | |
|---|---|
When we set up projects that reuse |
qmake can access an environment variable such as CPPLIBS from inside a project file using the syntax $$(CPPLIBS).
qmake can also include other project file (fragments).
For example, the project file in Example 7.1 includes a .pri file located in a directory relative to your environment variable CPPLIBS.
Example 7.1. src/qapp-gui/qapp-gui.pro
include ($$(CPPLIBS)/utils/useutils.pri) TEMPLATE = app # Input HEADERS += messager.h # ORDER MATTERS: main uses messager, so compile messager first SOURCES += messager.cpp main.cpp
The command
qmake -project
produces a project file that contains information based on the contents of the current working directory.
In particular, qmake cannot know about external libraries that you may need to build your project.
So, if your project depends on an external library, you must edit the project file and add assignments to three of the variables.
For example, suppose we are developing an application that uses our utils library.
The header files are located in $CPPLIBS/utils
and
the lib shared object files are located in $CPPLIBS.
Then we must add the following lines to the project file
INCLUDEPATH += $$(CPPLIBS)/utils # the source header files LIBS += -L$$(CPPLIBS) # add this to the lib search path LIBS += -lutils # link with libutils.so
Assignments to the LIBS variable generally contain two kinds of linker switches that are passed directly to the compiler and the linker.
For more information about what the linker switches mean see Section C.3
| Generated: $Date: 2009-09-08 12:15:32 -0400 (Tue, 08 Sep 2009) $ | © 2009 Alan Ezust and Paul Ezust. |