Creating a project for the library

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:
  1. Launch Qt Creator.
  2. In the File menu, choose New File or Project...
  3. 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...
  4. In the Location page of the Empty Qt Project dialog, name the project QtLibrary, then click Next.
  5. 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.

    To define a kit, you must first define toolchain settings (e.g., compiler, debugger), as explained in "Configuring a toolchain in Qt Creator".

  6. 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.

  7. 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.