- Compile qt5 on windows
- Установка QT под Windows и правильные Helloworld’ы 🙂
- Qt Documentation
- Contents
- Supported Configurations
- Deployment and Other Issues
- Where to Go from Here
- Visual Studio Tools
- Qt Documentation
- Contents
- Step 1: Install the License File (Commercially Licensed Qt Only)
- Step 2: Unpack the Archive
- Step 3: Set the Environment Variables
- Step 4: Build the Qt Library
- Parallel Builds
- Step 5: Build the Qt Documentation
- Building Qt 5 from Git
- Contents
- System Requirements
- All desktop platforms
- Documentation (optional)
- SSL (optional)
- Linux/X11
- apt-get build-dep
- Convenience packages (Ubuntu 11.10 — 12.10 only)
- Build essentials
- Libxcb
- OpenGL support
- Accessibility
- Qt WebKit
- Qt WebEngine
- Qt Multimedia
- QDoc Documentation Generator Tool
- macOS
- Windows
- Windows Graphics Drivers
- ANGLE dependencies
- Supported Compilers on Windows
- Windows Build environment
- Configuring Visual Studio 2013 on Windows 8, 8.1 & 10
- Configuring MinGW on Windows 8, 8.1 & 10
- ICU on Windows
- Getting the source code
- Getting the Qt 5.15 LTS Commercial source code
- Cloning all the Qt submodules
- Cloning specific Qt submodule
- Getting the submodule source code
- Configuring and Building
- Building Qt WebKit
- Windows
- Installing (Linux / OS X)
- Cleaning
- Getting updates
- Using latest branches in the submodules
- Issues
- Linux
- configure fails with «No QPA platform plugin enabled!» (Linux)
- configure fails with errors like «cannot stat file . «
- configure fails to enable qdoc on Debian
- qmlscene segfaults «Cannot create platform GL context, none of GLX, EGL, DRI2 is enabled» (Linux)
- WebKit doesn’t compile, missing ICU
- on Ubuntu/Debian:
- on Fedora:
- Qt D-Bus fails to build due to «inconsistent user-defined literal suffixes»
- cc1: fatal error: .pch/release-shared/QtGui: No such file or directory
- (void_(QQmlDataLoaderThread::)(QQmlDataBlob),_QQmlDataBlob*_const&)’_isn’t_defined»> ld: hidden symbol `void QQmlThread::postMethodToThread (void (QQmlDataLoaderThread::)(QQmlDataBlob), QQmlDataBlob* const&)’ isn’t defined
- Windows
- Debugging OpenGL issues (Windows)
- Questions and comments
Compile qt5 on windows
БлогNot. Установка QT под Windows и правильные Helloworld’ы 🙂
Установка QT под Windows и правильные Helloworld’ы 🙂
QT — ещё один мегаглючный популярный инструмент для разработки на C++. Во всяком случае, если Вы заглянете в тематический раздел Киберфорума, Вы увидите, что вместе с Visual C++ (Studio) и Builder именно Qt образует «большую тройку» современных сред разработки для C++. К тому же, сторонники Qt говорят, что только он изначально соблюдает концепцию ООП и весь из себя кроссплатформенный 🙂 Мдя, ну и бесплатный open source, конечно.
Как нам поставить и настроить это чудо под обычную 32- (64-) разрядную Windows? Смотрим официальный сайт, не ленимся нажать Show downloads.
Онлайн-сборки инсталлятора могут называться вроде
Увы, они будут докачивать порядка 800 Мб при установке и, по статистике, чаще становятся криво.
Офлайн-сборки (нажать Show Downloads на странице загрузок) могут называться, например
Это значит что они — с собственным компилятором MinGW и под 32-разрядную Windows. Есть еще сборки, предназначенные для работы с компилятором Visual Studio, тогда в имени сборки есть «studio». Не советую их, даже если установлен полный Visual Studio.
Скачать, установить. Актуальная версия 5.2.1 включает в себя IDE под названием Qt Creator, ставшее более-менее полноценным, во всяком случае, после пары ухищрений заработала отладка.
Запускаем установщик, по умолчанию будет предложен путь установки C:\Qt\Qt5.2.1 , не стоит его менять. Включаем компоненты Qt, MinGW, Qt Creator, Sources — необязательно.
Возможные проблемы при запуске QT Creator:
1. Ошибки при запуске (отсутствует libstdc++-6.dll и т.п.)
В чём дело: в переменных окружения не определена библиотека Qt и не прописан путь к компилятору. Исправляем ситуацию – создаем в переменных среды переменную QTDIR , содержащую значение
Кроме того, в системную переменную Path через точку с запятой прописываем пути
Как это сделать:
Windows XP: Мой компьютер, Свойства, Дополнительно, Переменные среды, Path, Изменить
Windows 7: Мой компьютер, Свойства, Дополнительные параметры системы, Переменные среды, Системные переменные, Path, Изменить
Это необходимо сделать также для того, чтобы собранные Вами приложения могли запускаться из проводника Windows или другого файл-менеджера.
2. Запускается, но присутствуют сообщения об ошибках (например, «Точка входа в процедуру __gxx_personality_v0 не найдена в библиотеке libstdc++-6.dll«).
В чём дело: кривые сборки Qt Creator. Собирайте компилятор MinGW вручную (в инете об этом есть) или поставьте QT Creator 3.0.1, основанный на сборке Qt 5.2.1 (файл qt-opensource-windows-x86-mingw48_opengl-5.2.1.exe ), в нём такого бага не наблюдалось.
3. На работает отладка и т.п. Не исключено, что по умолчанию вообще работает только подсветка кода 🙂
В чём дело: кривизна-с. В меню Инструменты, Параметры, на вкладке Сборка и запуск, Профили Qt проверяем, что имеется автоопределённая связка Qt 5.2.1 + MinGW 32bit, это добавляет Qt Creator. На вкладке Сборка и запуск, Комплекты (в немного более ранних сборках — Инструментарии) должна быть автоопределенная связка инструментов Desktop Qt 5.2.1 MinGW 32bit, эту связку также добавляет Qt Creator, но в ней может быть указан неправильный отладчик, а редактированию она не поддается. У меня помогло просто создание новой связки с помощью кнопки Добавить, ей присваиваем какое-либо другое имя, например, Desktop QT 5.2.1 MinGW Patched, нажимаем кнопку Сделать по умолчанию. В нижней части окна для новой связки необходимо выбрать такие же параметры как и для автоопределенной (Desktop, Локальный ПК (по умолчанию для Desktop), MinGW (x86 32bit) — если желаете, можно и через Visual Studio компилировать, будет ещё медленнее), но указать другой отладчик, воспользовавшись кнопкой Управление, Добавить, Обзор. В открывшемся окне указываем путь к отладчику вида C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\gdb.exe и нажимаем Применить.
4. Что ещё проверить и настроить перед созданием первого проекта.
Запускаем Qt Creator, выбираем пункт главного меню Инструменты, Параметры. на вкладке Текстовый редактор, Шрифт и цвета устанавливаем понравившийся шрифт (Courier New или другой моноширинный шрифт для листингов — рулит), на вкладке Текстовый редактор, Поведение выбираем кодировку файлов, по умолчанию Юникод (UTF-8). На вкладке Сборка и запуск, Основное указываем папку проектов, например, C:\Qt\Projects (эту папку надо предварительно создать; в пути к ней, как и к другим папкам Qt , не должно быть символов кириллицы и/или пробелов; имя пользователя в системе — тоже латиницей).
Теперь два главных действия должно быть легко выполнить:
- меню Отладка, Начать отладку, Начать отладку или клавиша F5
- меню Сборка, Запустить или комбинация клавиш Ctrl+R
Можно попробовать. Сначала консольное приложение: меню Файл, Новый файл или проект, Приложения, Консольное приложение Qt. Только встроенный код ничего не делает, а в инете и книгах обычно неработающие «Hello, world». Напишем работающий main.cpp 🙂
Теперь попробуем «приложение с интерфейсом»: меню Файл, Новый файл или проект, создать приложение QT Widgets. Текст модуля main.cpp :
Жмём Файл, Закрыть все документы и проекты — и вернёмся к начальному окну, готовые к новым подвигам 🙂
P.S. Ну и проблема ещё в том, что в инете и книгах большинство примеров — по QT4, а в QT5 есть заметные отличия, самое очевидное —
Подробнее здесь. А вот тут — много примеров с исходниками именно по QT5.
Ниже можно скачать оффлайн-сборку QT 5.2.1 с QT Creator и компилятором MinGW. При полной установке она обеспечивает нормальную работу приложения и не лезет в инет за дополнительными компонентами.
Скачать оффлайн-сборку QT 5.2.1 с QT Creator и компилятором MinGW в файле .exe, 634 Мб
Как слинковать приложение QT статически для работы на другом компьютере? DLL Collector
Как сделать Windows-инсталлятор для приложения на QT? InnoSetup
Qt Documentation
Contents
Qt’s support for different Windows platforms is extensive and mature.
Before you get started, ensure that your development environment fulfills the requirements.
To download and install Qt for Windows, follow the instructions on the Getting Started with Qt page.
Supported Configurations
The following configurations are supported.
Operating System | Architecture | Compiler | Notes |
---|---|---|---|
Windows 10 | x86 and x86_64 | MSVC 2019, MSVC 2017, MSVC 2015, MinGW 8.1 | |
Windows 8.1 | x86 and x86_64 | MSVC 2019, MSVC 2017, MinGW 8.1 | |
Windows 7 | x86 and x86_64 | MSVC 2019, MSVC 2017, MinGW 8.1 | MinGW-builds GCC 8.1.0 (x86) |
Deployment and Other Issues
The pages below covers specific issues and recommendations for creating Windows applications.
Where to Go from Here
We invite you to explore the rest of Qt. We prepared overviews which help you decide which APIs to use and our examples demonstrate how to use our API.
- Qt Overviews — list of topics about application development
- Examples and Tutorials — code samples and tutorials
- Qt Reference Pages — a listing of C++ and QML APIs
- ActiveX in Qt
Qt’s vibrant and active community site, http://qt.io houses a wiki, a forum, and additional learning guides and presentations.
Visual Studio Tools
The Qt VS Tools allows programmers to create, build, debug and run Qt applications from within non-Express versions of Microsoft Visual Studio 2013 and later. The add-in contains project wizards, Qt project import/export support, integrated Qt resource manager and automated build setup for the Qt Meta-Object Compiler, User Interface Compiler, and Resource Compiler.
В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Qt Documentation
Contents
This page describes the process of configuring and building Qt for Windows. Before building, there are some requirements that are given in more detail in the Qt for Windows — Requirements document.
You can download the Qt 5 sources from the Downloads page. For more information, visit the Getting Started with Qt page.
Step 1: Install the License File (Commercially Licensed Qt Only)
If you use Qt with a commercial license, the Qt tools look for a local license file. If you are using a binary installer or the commercial Qt Creator, your licenses are automatically fetched and stored in your local user profile ( %USERPROFILE%\AppData\Roaming\Qt\qtlicenses.ini file).
If you do not use any binary installer or Qt Creator, you can download the respective license file from your Qt Account Web portal and save it to your user profile as %USERPROFILE%\.qt-license . If you prefer a different location or file name, you need to set the QT_LICENSE_FILE environment variable to the respective file path.
Step 2: Unpack the Archive
Uncompress the files into the directory you want Qt installed; e.g. C:\Qt\%VERSION% .
Note: The install path must not contain any spaces or Windows specific file system characters.
Step 3: Set the Environment Variables
We recommend creating a desktop link that opens a command prompt with the environment set up similar to the Command Prompt menu entries provided by Visual Studio. This is done by creating an application link passing a .cmd file setting up the environment and the command line option /k (remain open) to cmd.exe .
Assuming the file is called qt5vars.cmd and the Qt folder is called Qt-5 and located under C:\Qt :
A desktop link can then be created by specifying the command %SystemRoot%\system32\cmd.exe /E:ON /V:ON /k C:\Qt\qt5vars.cmd as application and C:\Qt\Qt-5 as working directory.
Note: Setups for MinGW are similar; they differ only in that the bin folder of the installation should be added to the path instead of calling the Visual Studio setup script. For MinGW, please make sure that no sh.exe can be found in the path, as it affects mingw32-make .
Settings required by the additional libraries (see Qt for Windows — Requirements) should also go this file below the call to the Windows SDK setup script.
Step 4: Build the Qt Library
The default behavior of configure is to create an in-source build of Qt 5. If you want to install Qt 5 to a separate location, you need to specify the command line option -prefix . Alternatively, the command line option -developer-build creates an in-source build for developer usage.
To configure the Qt library for a debug build for your machine, type the following command in the command prompt:
The Configure Options page contains more information about the configure options.
To build Qt using jom, type:
If you do not have jom installed, type:
If an installation prefix was given, type jom install , nmake install or mingw32-make install .
Note: If you later need to reconfigure and rebuild Qt from the same location, ensure that all traces of the previous configuration are removed by entering the build directory and typing nmake distclean before running configure again.
Parallel Builds
jom is a replacement for nmake which makes use of all CPU cores and thus speeds up building.
Step 5: Build the Qt Documentation
For the Qt reference documentation to be available in Qt Assistant, you must build it separately:
This will build the documentation in the build folder. If you have installed Qt in a separate location, you will also need to install the documentation:
В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Building Qt 5 from Git
En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh
This article provides hints for checking out and building the Qt 5 repositories. This is primarily for developers who want to contribute to the Qt library itself, or who want to try the latest unreleased code.
If you simply want to build a specific release of Qt from source to use the libraries in your own project, you can download the source code from the Official Releases page or the Archive. Alternatively, commercial customers can download the Source Packages via the Qt Account portal.
Contents
System Requirements
All desktop platforms
- Git (>= 1.6.x)
- Perl (>=5.14)
- Python (>=2.6.x)
- A working C++ compiler
For more detailed information, see Building Qt Sources
Documentation (optional)
SSL (optional)
For Windows, bison, flex and gperf are provided with the source code at c:\pathToQt\gnuwin32\bin. Get Ruby from http://rubyinstaller.org/. You can download the precompiled ICU packages from download.qt.io, or see Compiling-ICU to compile your own.
Linux/X11
apt-get build-dep
Ubuntu/Debian based systems have a convenient way of installing build-depends for any package:
RPM-based distros with yum offer a similar tool called yum-builddep.
Note: if you see the following error message while running the commands above on Ubuntu:
Then you will need to enable the «Source code» option in Software and Updates > Ubuntu Software under the «Downloadable from the Internet» section. This setting can also be found by running software-properties-gtk.
Convenience packages (Ubuntu 11.10 — 12.10 only)
For Ubuntu/Debian, Gabor Loki has provided a custom PPA with the sedkit-env-webkit meta package that installs all required dependencies for building Qt/Qt WebKit. You can add the PPA by calling:
For other distros, get the separate components below.
Build essentials
Ubuntu and/or Debian: | sudo apt-get install build-essential perl python git |
Fedora 30 | su — -c «dnf install perl-version git gcc-c++ compat-openssl10-devel harfbuzz-devel double-conversion-devel libzstd-devel at-spi2-atk-devel dbus-devel mesa-libGL-devel» |
OpenSUSE: | sudo zypper install git-core gcc-c++ make |
Libxcb
Libxcb is now the default window-system backend for platforms based on X11/Xorg, and you should therefore install libxcb and its accompanying packages. Qt5 should build with whatever libxcb version is available in your distro’s packages (but you may optionally wish to use v1.8 or higher to have threaded rendering support). The README lists the required packages.
Ubuntu/Debian: | sudo apt-get install ‘^libxcb.*-dev’ libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev | ||||||||||||
Fedora 30: | su — -c «dnf install libxcb libxcb-devel xcb-util xcb-util-devel xcb-util-*-devel libX11-devel libXrender-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel libdrm-devel libXcursor-devel libXcomposite-devel» | ||||||||||||
OpenSUSE 12+: | sudo zypper in xorg-x11-libxcb-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-renderutil-devel xcb-util-wm-devel xorg-x11-devel libxkbcommon-x11-devel libxkbcommon-devel libXi-devel | ||||||||||||
ArchLinux/Manjaro: | sudo pacman -S —needed libxcb xcb-proto xcb-util xcb-util-image xcb-util-wm libxi | ||||||||||||
Chakra Linux: | Install the ArchLinux packages, plus xcb-util-keysyms. It’s available from CCR. | ||||||||||||
Mandriva/ROSA/Unity: | urpmi ‘pkgconfig(xcb)’ ‘pkgconfig(xcb-icccm)’ ‘pkgconfig(xcb-image)’ ‘pkgconfig(xcb-renderutil)’ ‘pkgconfig(xcb-keysyms)’ ‘pkgconfig(xrender)’ | ||||||||||||
Linux Mint: | apt-get install libx11-xcb-dev libxcb-composite0-dev libxcb-cursor-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-present-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-sync-dev libxcb-util-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-xkb-dev libxcb-xtest0-dev libxcb1-dev | ||||||||||||
Centos 5/6 | Install missing Qt build dependencies: Install Red Hat DevTools 1.1 for CentOS-5/6 x86_64, they are required due to outdated GCC shipped with default CentOS: Initialise your newly installed dev tools: For more info on preparing the environment on CentOS, see this thread. | ||||||||||||
Centos 7 | Update to gcc 7: Install missing Qt build dependencies (Qt 5.13): OpenGL supportFor Qt Quick 2, a graphics driver with native OpenGL 2.0 support is highly recommended. AccessibilityIt is recommended to build with accessibility enabled, install libatspi 2 and libdbus-1 development packages. Qt WebKit
Qt WebEngine
| ||||||||||||
OpenSUSE: | sudo zypper install alsa-devel dbus-1-devel libXcomposite-devel libXcursor-devel libXrandr-devel libXtst-devel mozilla-nspr-devel mozilla-nss-devel gperf bison nodejs10 nodejs10-devel |
Qt Multimedia
You’ll need at least alsa-lib (>= 1.0.15) and gstreamer (>=0.10.24) with the base-plugins package.
Ubuntu/Debian: | sudo apt-get install libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev | ||
Fedora 30: |
Ubuntu/Debian: | sudo apt install libclang-6.0-dev llvm-6.0 |
Fedora 30: |