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-qmake.html
|
|
|
|
|
\page creator-tool-chains.html
|
2013-10-31 11:40:06 +01:00
|
|
|
\nextpage creator-debuggers.html
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-08-24 08:31:01 +02:00
|
|
|
\title Adding Compilers
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-08-24 14:20:59 +02:00
|
|
|
Qt is supported on a variety of 32-bit and 64-bit platforms, and can
|
|
|
|
|
usually be built on each platform with GCC, a vendor-supplied compiler, or
|
2012-09-03 17:50:37 +02:00
|
|
|
a third party compiler. In \QC, a \l{glossary-buildandrun-kit}{kit}
|
2017-02-21 14:47:56 +01:00
|
|
|
specifies the compiler and other necessary tools for building an application
|
|
|
|
|
for and running it on a particular platform.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-08-24 14:20:59 +02:00
|
|
|
\QC automatically detects the compilers that are registered by your system
|
2014-03-14 16:02:01 +01:00
|
|
|
or by an installer. You can add compilers to build applications by using other
|
2012-08-24 14:20:59 +02:00
|
|
|
compilers or by using additional versions of the automatically detected
|
|
|
|
|
compilers:
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li GNU Compiler Collection (GCC) is a compiler for Linux and
|
2016-08-03 16:46:29 +02:00
|
|
|
\macos.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li MinGW (Minimalist GNU for Windows) is a native software port of GCC
|
2011-09-27 11:55:44 +02:00
|
|
|
and GNU Binutils for use in the development of native Microsoft
|
|
|
|
|
Windows applications on Windows. MinGW is
|
2014-03-14 16:02:01 +01:00
|
|
|
distributed together with \QC and Qt installers for Windows.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Linux ICC (Intel C++ Compiler) is a group of C and C++ compilers
|
2011-09-27 11:55:44 +02:00
|
|
|
for Linux.
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Clang is a C, C++, Objective C, and Objective C++ front-end for the
|
2016-08-03 16:46:29 +02:00
|
|
|
LLVM compiler for Windows, Linux, and \macos.
|
2013-02-14 15:18:19 +01:00
|
|
|
|
2017-02-07 10:03:42 +01:00
|
|
|
\li Nim is the Nim Compiler for Windows, Linux, and \macos.
|
|
|
|
|
|
2014-04-09 15:13:05 +02:00
|
|
|
\li QCC is the interface for compiling C++ applications for QNX.
|
|
|
|
|
|
2011-09-27 11:55:44 +02:00
|
|
|
\endlist
|
|
|
|
|
|
2014-04-09 15:13:05 +02:00
|
|
|
To build an application using GCC, MinGW, Clang, or QCC, specify the path
|
2012-08-24 14:20:59 +02:00
|
|
|
to the directory where the compiler is located and select
|
2011-09-27 11:55:44 +02:00
|
|
|
the application binary interface (ABI) version from the list of available
|
|
|
|
|
versions. You can also create a custom ABI definition.
|
2015-04-24 10:31:27 +02:00
|
|
|
For QCC, also specify the path to the QNX Software Development Platform (SDP).
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
You specify the compiler to use for each kit in \uicontrol Tools >
|
|
|
|
|
\uicontrol Options > \uicontrol {Build & Run} > \uicontrol Kits.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2017-02-07 10:03:42 +01:00
|
|
|
To add C or C++ compilers:
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
2015-07-01 12:48:38 +02:00
|
|
|
\li Select \uicontrol Tools > \uicontrol Options >
|
2016-10-25 17:34:27 +02:00
|
|
|
\uicontrol {Build & Run} > \uicontrol Compilers > \uicontrol Add,
|
|
|
|
|
then select a compiler in the list, and then select \uicontrol C or
|
|
|
|
|
\uicontrol C++ to add a C or C++ compiler.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\image qtcreator-toolchains.png
|
|
|
|
|
|
2015-07-01 12:48:38 +02:00
|
|
|
To clone the selected compiler, select \uicontrol Clone.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2015-07-01 12:48:38 +02:00
|
|
|
\li In the \uicontrol Name field, enter a name for the compiler to
|
|
|
|
|
identify it in \QC.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2015-07-01 12:48:38 +02:00
|
|
|
\li In the \uicontrol {Compiler path} field, enter the path to the
|
|
|
|
|
directory where the compiler is located.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Platform codegen flags} field, check the flags passed
|
2013-11-01 15:19:46 +01:00
|
|
|
to the compiler that specify the architecture on the target
|
|
|
|
|
platform.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Platform linker flags} field, check the flags passed to
|
2013-11-01 15:19:46 +01:00
|
|
|
the linker that specify the architecture on the target platform.
|
|
|
|
|
The linker flags are used only when building with Qbs.
|
|
|
|
|
|
2012-08-24 14:20:59 +02:00
|
|
|
The other settings to specify depend on the compiler.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2015-07-01 12:48:38 +02:00
|
|
|
\li In the \uicontrol ABI field, provide an identification for the
|
|
|
|
|
target architecture. This is used to warn about ABI mismatches
|
|
|
|
|
within the kits.
|
|
|
|
|
|
2011-09-27 11:55:44 +02:00
|
|
|
\endlist
|
|
|
|
|
|
2017-02-07 10:03:42 +01:00
|
|
|
\section1 Adding Nim Compilers
|
|
|
|
|
|
|
|
|
|
To build an application using the Nim Compiler, select \uicontrol Tools >
|
|
|
|
|
\uicontrol Options > \uicontrol {Build & Run} > \uicontrol Compilers >
|
|
|
|
|
\uicontrol Add > \uicontrol Nim, and specify the path to the directory where
|
|
|
|
|
the compiler is located.
|
|
|
|
|
|
2013-02-14 15:18:19 +01:00
|
|
|
\section1 Adding Custom Compilers
|
|
|
|
|
|
|
|
|
|
To add a compiler that is not listed above or a remote compiler, use the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol Custom option and specify the paths to the directories where the
|
2013-02-14 15:18:19 +01:00
|
|
|
compiler and make tool are located and options for the compiler.
|
|
|
|
|
|
|
|
|
|
\image creator-compilers-custom.png
|
|
|
|
|
|
|
|
|
|
To add other compilers:
|
|
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Select \uicontrol Tools > \uicontrol Options > \uicontrol {Build & Run} >
|
2016-10-25 17:34:27 +02:00
|
|
|
\uicontrol Compilers > \uicontrol Add > \uicontrol Custom >
|
|
|
|
|
\uicontrol C or \uicontrol C++.
|
2013-02-14 15:18:19 +01:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol Name field, enter a name for the compiler.
|
2013-02-14 15:18:19 +01:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Compiler path} field, enter the path to the directory
|
2013-02-14 15:18:19 +01:00
|
|
|
where the compiler is located.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Make path} field, enter the path to the directory where
|
2013-02-14 15:18:19 +01:00
|
|
|
the make tool is located.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol ABI field, specify the ABI version.
|
2013-02-14 15:18:19 +01:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Predefined macros} field, specify the macros that the
|
2013-02-14 15:18:19 +01:00
|
|
|
compiler enables by default. Specify each macro on a separate line,
|
|
|
|
|
in the following format: MACRO[=value].
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Header paths} field, specify the paths to directories
|
2013-02-14 15:18:19 +01:00
|
|
|
that the compiler checks for headers. Specify each path on a
|
|
|
|
|
separate line.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {C++11 flags} field, specify the flags that turn on
|
2013-02-14 15:18:19 +01:00
|
|
|
C++11 support in the compiler.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Qt mkspecs} field, specify the path to the directory
|
2013-02-14 15:18:19 +01:00
|
|
|
where mkspecs are located. Usually, the path is specified relative
|
|
|
|
|
to the Qt mkspecs directory.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Error parser} field, select the error parser to use.
|
|
|
|
|
Select \uicontrol Custom, and then select \uicontrol {Customer Parser Settings}
|
2013-11-01 15:19:46 +01:00
|
|
|
to specify settings for a custom parser:
|
|
|
|
|
|
|
|
|
|
\image qtcreator-custom-parser.png
|
|
|
|
|
|
2015-12-16 21:04:45 +01:00
|
|
|
The custom error parser enables you to capture errors and warnings separately.
|
|
|
|
|
You can configure the error parser in the \uicontrol Error tab and the warning
|
|
|
|
|
parser in the \uicontrol Warning tab:
|
|
|
|
|
|
2013-11-01 15:19:46 +01:00
|
|
|
\list 1
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Error message capture pattern} field, specify
|
2013-11-01 15:19:46 +01:00
|
|
|
a regular expression to define what is an error. The custom
|
|
|
|
|
parser matches the compile output line by line against the
|
2014-12-11 15:43:19 +01:00
|
|
|
regular expression and displays errors in the \uicontrol Issues
|
2013-11-01 15:19:46 +01:00
|
|
|
output pane. Create regular expression groups that contain
|
|
|
|
|
the file name, line number and error message.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Capture Positions} field, map the regular
|
|
|
|
|
expression groups to \uicontrol {File name}, \uicontrol {Line number},
|
|
|
|
|
and \uicontrol Message.
|
2013-11-01 15:19:46 +01:00
|
|
|
|
2015-12-16 21:04:45 +01:00
|
|
|
\li In the \uicontrol {Capture Output Channels} field, specify whether
|
|
|
|
|
messages from standard output, standard error, or both channels
|
|
|
|
|
should be captured.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li In the \uicontrol {Test} group, you can test how the message that
|
|
|
|
|
you enter in the \uicontrol {Error message} field is matched when
|
2013-11-01 15:19:46 +01:00
|
|
|
using the current settings.
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
2013-02-14 15:18:19 +01:00
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
\section1 Troubleshooting MinGW Compilation Errors
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
If error messages displayed in the \uicontrol {Compile Output} pane contain
|
2015-07-01 12:48:38 +02:00
|
|
|
paths where slashes are missing (for example, \c {C:QtSDK}),
|
2011-09-27 11:55:44 +02:00
|
|
|
check your PATH variable. At the command line, enter the following commands:
|
|
|
|
|
|
|
|
|
|
\code
|
|
|
|
|
where sh.exe
|
|
|
|
|
where make.exe
|
|
|
|
|
where mingw32-make.exe
|
|
|
|
|
\endcode
|
|
|
|
|
|
|
|
|
|
If these commands show paths, they have been added to the global PATH
|
|
|
|
|
variable during the installation of a tool chain based on Cygwin or MinGW,
|
|
|
|
|
even though this is against Windows conventions.
|
|
|
|
|
|
|
|
|
|
To keep working with the third-party tool chain, create a new shell link
|
|
|
|
|
that adds the required paths (as Visual Studio and Qt do). The shell link
|
|
|
|
|
must point to cmd.exe, as illustrated by the following example:
|
|
|
|
|
|
|
|
|
|
\c {C:\Windows\System32\cmd.exe /K C:\path_to\myenv.bat}
|
|
|
|
|
|
|
|
|
|
where the /K parameter carries out the command specified in the bat file.
|
|
|
|
|
|
|
|
|
|
Create the myenv.bat file at \e path_to, which should be in a convenient
|
|
|
|
|
location. In the file, specify the paths to the tool chains. For example,
|
|
|
|
|
|
|
|
|
|
\c {set PATH=C:\path1;C:\path2;%PATH%}
|
|
|
|
|
|
|
|
|
|
where \e path1 and \e path2 are paths to the tool chains.
|
|
|
|
|
|
|
|
|
|
Finally, remove the paths from the global PATH, reboot the computer, and
|
|
|
|
|
run the \c where commands again to verify that the global PATH is now clean.
|
|
|
|
|
|
|
|
|
|
You can use the shell link to run the tools in the third-party tool chains.
|
|
|
|
|
|
|
|
|
|
*/
|