The first stage in generating a library for use by Qt apps is to create a project in Qt Creator and define library functions.
This example builds a Qt project that compiles into a dynamic library (
.so) file.
The library exports a public function that can be called by application code.
To create a Qt project and configure its project file:
-
Launch Qt Creator.
-
In the File menu, choose New File or Project...
-
In the resulting dialog, choose Other Project from the list on the left,
then Empty Qt Project from the list in the middle, and then click
Choose...
-
In the Location page of the Empty Qt Project dialog,
name the project QtLibrary, then click Next.
-
In the Kits page, choose the kit that you configured when setting up Qt Creator
(e.g., QNX SDP 6.6 – OMAP5432), then click Next.
-
In the Summary page, click Finish to save your new project's settings.
Qt Creator creates the new project and displays the empty QtLibrary.pro file in the
editing area.
-
Add these lines to this file:
# We're building a library
TEMPLATE = lib
VERSION = 1.0
This instructs Qt Creator to build a dynamic library file with the indicated version number.
The resulting file will be called
libQtLibrary.so.1.0.
Note:
The project file can define many variables that affect how
qmake builds the project;
for the full list, see the
Variables | QMake reference in Digia's online Qt documentation.