2011-09-27 11:55:44 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-09-27 11:55:44 +02:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** This file is part of the Qt Creator documentation.
|
2011-09-27 11:55:44 +02:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-09-27 11:55:44 +02:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** GNU Free Documentation License Usage
|
2011-09-27 11:55:44 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Free
|
|
|
|
|
** Documentation License version 1.3 as published by the Free Software
|
2016-01-15 14:51:16 +01:00
|
|
|
** Foundation and appearing in the file included in the packaging of
|
|
|
|
|
** this file. Please review the following information to ensure
|
|
|
|
|
** the GNU Free Documentation License version 1.3 requirements
|
|
|
|
|
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
|
2011-09-27 11:55:44 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
// NOTE: the sections are not ordered by their logical order to avoid
|
|
|
|
|
// reshuffling the file each time the index order changes (i.e., often).
|
|
|
|
|
// Run the fixnavi.pl script to adjust the links to the index order.
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-03-17 12:18:12 +01:00
|
|
|
\contentspage {Qt Creator Manual}
|
2011-09-27 11:55:44 +02:00
|
|
|
\previouspage creator-project-opening.html
|
|
|
|
|
\page creator-project-qmake-libraries.html
|
2011-12-13 11:52:47 +01:00
|
|
|
\nextpage creator-project-wizards.html
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\title Adding Libraries to Projects
|
|
|
|
|
|
|
|
|
|
In addition to Qt libraries, you can add other libraries to your projects.
|
2012-10-08 14:18:26 +02:00
|
|
|
The way the library is added depends on the type and location of the
|
|
|
|
|
library. You can add a system library, your own library, or a 3rd party
|
|
|
|
|
library. The library can be located either in the build tree of the
|
2011-09-27 11:55:44 +02:00
|
|
|
current project or in another build tree.
|
|
|
|
|
|
|
|
|
|
\image qtcreator-add-library-wizard.png "Add Library wizard"
|
|
|
|
|
|
|
|
|
|
Because system libraries do not typically change and are often found by
|
|
|
|
|
default, you do not need to specify the path to the library or to its
|
2012-10-08 14:18:26 +02:00
|
|
|
includes when you add it. You can use \c{pkg-config} to query system
|
|
|
|
|
libraries during compilation.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
For your own libraries and 3rd party libraries, you need to specify
|
|
|
|
|
the paths. \QC tries to guess the include path for an external library,
|
|
|
|
|
but you need to check it and modify it if necessary. \QC automatically
|
|
|
|
|
adds the include path for an internal library.
|
|
|
|
|
|
|
|
|
|
For all libraries, select the target platforms for the application, library,
|
|
|
|
|
or plugin.
|
|
|
|
|
|
|
|
|
|
Specify whether the library is statically or dynamically linked. For a
|
|
|
|
|
statically linked internal library, \QC adds dependencies
|
|
|
|
|
(PRE_TARGETDEPS) in the project file.
|
|
|
|
|
|
|
|
|
|
Depending on the development platform, some options might be detected
|
2014-12-11 15:43:19 +01:00
|
|
|
automatically. For example, on OS X, the library type (\uicontrol Library or
|
|
|
|
|
\uicontrol Framework) is detected automatically and the option is hidden. However,
|
2014-05-02 12:44:45 +02:00
|
|
|
if you develop on another platform than OS X and want to build your
|
|
|
|
|
project for OS X, you must specify the library type.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
The default convention on Windows is that the debug and release versions
|
|
|
|
|
of a library have the same name, but are placed in different subdirectories,
|
|
|
|
|
usually called \e debug and \e release. If the library path does not contain
|
|
|
|
|
either of these folders, you cannot select the option to place the libraries
|
|
|
|
|
in separate folders.
|
|
|
|
|
|
|
|
|
|
Alternatively, the letter \e d can be added to the library name for the
|
|
|
|
|
debug version. For example, if the release version is called example.lib,
|
|
|
|
|
the debug version is called exampled.lib. You can specify that the letter
|
|
|
|
|
is added for the debug version and removed for the release version.
|
2014-12-11 15:43:19 +01:00
|
|
|
If the library name ends in \e d, deselect the \uicontrol {Remove "d" suffix
|
2011-09-27 11:55:44 +02:00
|
|
|
for release version} option.
|
|
|
|
|
|
|
|
|
|
\QC supports code completion and syntax highlighting for the added
|
|
|
|
|
libraries once your project successfully builds and links to them.
|
|
|
|
|
|
|
|
|
|
\section1 To Add Libraries
|
|
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Projects pane, right-click the project name to open the
|
2012-03-14 14:17:31 +01:00
|
|
|
context menu and select
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Add Library}.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Follow the instructions of the wizard.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
For more information about the project file settings, see
|
2013-11-25 17:37:19 +01:00
|
|
|
\l{Declaring Other Libraries}.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\section1 Example of Adding Internal Libraries
|
|
|
|
|
|
|
|
|
|
The following example describes how to add a statically linked internal
|
|
|
|
|
library to your project.
|
|
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
2015-11-16 14:52:12 +01:00
|
|
|
\li Choose \uicontrol File > \uicontrol {New File or Project} >
|
|
|
|
|
\uicontrol Library > \uicontrol {C++ Library} to create the library.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
The \uicontrol {Introduction and Product Location} dialog opens.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\image qtcreator-add-library-wizard-ex-1.png "Introduction and Product Location dialog"
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Type field, select \uicontrol {Statically Linked Library}.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Name field, give a name for the library. For example,
|
2013-02-06 08:50:23 +01:00
|
|
|
\b mylib.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Follow the instructions of the wizard until you get to the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Project Management} dialog. In the \uicontrol {Add to project}
|
2013-02-06 08:50:23 +01:00
|
|
|
list, select a project. For example, \b myapp.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Projects pane, right-click the project name to open the
|
2012-03-14 14:17:31 +01:00
|
|
|
context menu and select
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Add Library > Internal Library > Next}.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Library field, select \b mylib and click \uicontrol Next.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Click \uicontrol Finish to add the following library declaration to the
|
2011-09-27 11:55:44 +02:00
|
|
|
project file:
|
|
|
|
|
|
|
|
|
|
\code
|
|
|
|
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/release/ -lmylib
|
|
|
|
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/debug/ -lmylib
|
|
|
|
|
else:unix: LIBS += -L$$OUT_PWD/../../../projects/mylib/ -lmylib
|
|
|
|
|
|
|
|
|
|
INCLUDEPATH += $$PWD/../../../projects/mylib
|
|
|
|
|
DEPENDPATH += $$PWD/../../../projects/mylib
|
|
|
|
|
|
|
|
|
|
win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/release/mylib.lib
|
|
|
|
|
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/debug/mylib.lib
|
2012-08-22 13:27:25 +02:00
|
|
|
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/libmylib.a
|
2011-09-27 11:55:44 +02:00
|
|
|
\endcode
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
*/
|