- building qt-creator from source
- Offline Qt Downloads
- Qt6 Source Packages
- Qt 6.5.1 Source Packages:
- Older Qt Versions
- Qt 5.15.x Source Packages
- 5.12.x Offline Installers
- Qt Creator
- Pre-releases
- Qt for Linux/X11 — Building from Source
- Step 1: Getting the Sources
- Step 2: Install Build Requirements
- Build Tools
- Compilers & Development Packages
- Step 3: Build the Qt Libraries and Tools
- Step 4: Using Qt
- Статическая компиляция Qt из исходного кода
- 1 ответ 1
- Building Qt Creator from Git on Ubuntu 22.04
- Contents
- 1. Install build tools
- 2. Install all the Ubuntu Qt 6 SDK packages
- 3. Install LLVM / Clang dependencies
- 4. Install Qt Creator dependencies
- 5. Get Qt Creator source code
- 6. Build Qt Creator
building qt-creator from source
Since qt-creator(4.11/4.12) integrated support for cmake’s source_groups, headers and sources are split in two separate folders. ‘Header-Files’,’Source-Files’ which is a bit annoying (not so annoying as the initial lack of subfolders. ). Because of that I downgraded a couple of time ago back to 4.10 till today one qt-creator issue-tracker topic was active again, what triggered me to dive in again.
To make it short, I decided to have a look if I can somehow merge both folders into one. For that I needed to be able to compile qt-creator from source-code. Which actually worked like a charme. Here the steps(hope I can recall all):
My setup: ubuntu mate/bionic
Obviously nothing is older than not maintained build instructions. These steps are valid for qt-creator 4.12 git-hash(91536ae7812e904334b0007445a64aecf3e120ad / 2020/04/23 )
sudo add-apt-repository ppa:beineri/opt-qt-5.12.0-bionic sudo apt-get update sudo apt-get install qt512-meta-full
In order for some environment-variables to be set you have to call:
source /opt/qt512/bin/qt512-env.sh
sudo apt-get install llvm-8 sudo apt-get install libclang-8-dev # not sure if clang-tools are needed: sudo apt-get install clang-8 clang-tools-8 export LLVM_INSTALL_DIR=/usr/lib/llvm-8
git clone --recursive https://code.qt.io/qt-creator/qt-creator.git # create a build-folder mkdir qt-creator-build cd qt-creator-build qmake -r ../qt-creator make -j8
btw, in order to merge «Source-Files» and «Header-Files» you only need to alter: src/plugins/cmakeprojectmanager/fileapidataextractor.cpp (lines at about 421, I copy the whole method, but I added only the marked lines):
FolderNode *createSourceGroupNode(const QString &sourceGroupName, const FilePath &sourceDirectory, FolderNode *targetRoot) < FolderNode *currentNode = targetRoot; if (!sourceGroupName.isEmpty()) < // new QString _srcgrpName = (sourceGroupName=="Header Files" || sourceGroupName=="Source Files") // new ? "Source" // new : sourceGroupName; // new const QStringList parts = _srcgrpName.split("\\"); // modified for (const QString &p : parts) < FolderNode *existingNode = Utils::findOrDefault(currentNode->folderNodes(), [&p](const FolderNode *fn) < return fn->displayName() == p; >); if (!existingNode) < auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p); node->setListInProject(false); node->setIcon(QIcon::fromTheme("edit-copy", ::Utils::Icons::COPY.icon())); existingNode = node.get(); currentNode->addNode(std::move(node)); > currentNode = existingNode; > > return currentNode; >
Hope that helps. (As always, this blog is mainly a reminder for myself. 😀 )
Offline Qt Downloads
We recommend you use the Qt Online Installer for first time installations and the Qt Maintenance Tool for changes to a current install.
- Qt6 source packages
- 5.15.x source packages
- 5.12.x Offline Installers
- Qt Creator
- Other downloads
- Pre-releases
Qt6 Source Packages
Qt 6.5.1 Source Packages:
The source code is available:
- For Windows users as a single zip file (1.2 G) ( Info )
- For Linux/macOS users as a tar.xz file (760 MB) ( Info )
You can get split source packages from here. Or visit the repository at code.qt.io.
Older Qt Versions
All older versions of Qt are available in the archive .
Qt 5.15.x Source Packages
The source code is available:
- For Windows users as a single zip file (962 MB) ( Info )
- For Linux/macOS users as a tar.xz file (560 MB) ( Info )
You can get split source packages from here. Or visit the repository at code.qt.io.
5.12.x Offline Installers
Qt offline installer is a stand-alone binary package including Qt libraries and Qt Creator.
Source packages & Other releases
The source code is available:
- For Windows users as a single zip file (831 MB) ( Info )
- For Linux/macOS users as a tar.xz file (486 MB) ( Info )
You can get split source packages from here. Or visit the repository at code.qt.io.
Qt Creator
Qt Creator 10.0.2 is released and it is available via Qt online installer. If you need a standalone installer, please select the file according to your operating system from the list below to get the latest Qt Creator for your computer.
The source code is available as a zip (65 MB) ( Info ) or a tar.gz (56 MB) ( Info ). Or visit the repository at code.qt.io.
Be sure to check if Qt is supported on your platform and read the installation notes that are located in the Qt Documentation .
Please check the individual downloads for licensing information.
Pre-releases
Looking for Qt 6.6 Beta? Packages can be downloaded from here.
Looking for Qt Creator 11.0 RC? Packages can be downloaded from here.
Qt for Linux/X11 — Building from Source
This page describes configuring and building Qt for Linux/X11 from sources. Note that it is typically easier to install the pre-built Qt libraries and tools via the Qt Online Installer. A lot of Linux distributions also provide Qt packages through their package manager. Build Qt from sources, however, if you want to customize Qt further or are using a distribution for which no binary Qt packages (in the right version) are available.
Distribution packagers can find further information on how to package Qt in the packaging recommendations.
Step 1: Getting the Sources
Qt sources can be installed in the Qt Online Installer. Source packages are also available as Git repositories, as archives in the Qt Account (commercial users), and on download.qt.io (open-source users).
If you install the sources through the Qt Online Installer, they will be available in the Qt installation directory, for example $HOME/Qt/6.5.1/Src .
If you downloaded the single source archive, extract it to a directory of your choice:
cd ~/dev tar xf ~/Downloads/qt-everywhere-src-6.5.1.tar.xz
Step 2: Install Build Requirements
Building Qt requires a build environment with tools, compilers, and development packages.
Build Tools
Tool | Supported Versions |
---|---|
CMake | Version 3.16 and newer (3.21 and newer for -static builds). |
Ninja | — |
Python | Version 3 |
Note: configure always uses the Ninja generator and build tool if a ninja executable is available. Ninja is cross-platform, feature-rich, performant, and recommended on all platforms. The use of other generators might work but is not officially supported.
Compilers & Development Packages
The following compilers and configurations are supported in Qt 6.5:
Distribution | Architecture | Compiler | Notes |
---|---|---|---|
Red Hat 8.4 | x86_64 | GCC 10 (toolset) | |
Red Hat 9.0 | x86_64 | GCC 11 | |
openSUSE 15.4 | x86_64 | GCC 9 | |
SUSE Linux Enterprise Server 15 SP4 | x86_64 | GCC 10 | |
Ubuntu 22.04 | x86_64 | GCC as provided by Canonical, GCC 11.x |
Other compilers and configurations might work but are not actively tested.
Qt also relies on the availability of various libraries and development packages, which are typically installed by the package manager of the respective resolution. See Qt for X11 Requirements for the details.
Step 3: Build the Qt Libraries and Tools
Run the ./configure script in the package directory to configure your build:
cd /tmp/qt-everywhere-src-6.5.1 ./configure
By default, Qt is configured for installation in the /usr/local/Qt-6.5.1 directory. This can be changed by using the -prefix option. See the list of configure options to tweak further.
Did configure run successfully? Then proceed with building the libraries and tools:
After building, you need to install the libraries and tools in the appropriate place (unless you enabled a developer build):
Note that this might require root access.
Step 4: Using Qt
After Qt is installed, you can start building applications with it.
If you work from the command line, consider adding the Qt tools to your default PATH . This is done as follows:
In .profile (if your shell is bash, ksh, zsh or sh), add the following lines:
PATH=/usr/local/Qt-6.5.1/bin:$PATH export PATH
In .login (if your shell is csh or tcsh), add the following line:
setenv PATH /usr/local/Qt-6.5.1/bin:$PATH
If you plan to use Qt from an IDE, you need to register the Qt version explicitly there. For Qt Creator, see Qt Creator: Adding Qt Versions.
© 2023 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 из исходного кода
Если я всё верно понял, то в систему должен установится Qt Creator статически, т.е. свои проекты я могу собирать единым файлом. Однако, в списках всех программ (dpgk) qt отсутствует. Как его запустить? Или я просто делаю неверно что-то или чего-то не понимаю? Скомпилированные файлы находятся здесь:
Подскажите, как грамотно собрать QT из исходников(обязательно статически, чтобы я мог наконец все используемые библиотеки вшить в исполняемый файл) и самое главное — запустить?
Вам не нужен статически собранный Qt Creator, Вам надо Qt статически собирать. По статической сборке Qt 4.8 море ссылок в поиске.
@ixSci судя по ссылке на репозиторий, откуда я выгружаю исходный код, я собираю qt таки. Но, повторюсь, он собрался, что делать дальше? Я читал, но обычно все заканчивается на сборке qt и все. Как это цеплять к creator не расписано.
QtCreator это просто IDE. Если у Вас статически собранные библиотеки, то при сборке проекта они будут скомпанованы с единый бинарный файл, вне зависимости от того, используете Вы QtCreator или нет. Почитайте что такое статические библиотеки в C/C++.
1 ответ 1
Итак, отвечаю на собственный вопрос, ибо так никто и не помог и пришлось разбираться. Для статической компиляции QT нужно следующее: Установить Qt Creator. Посмотреть в about версию используемого Qt. Иногда, для сборки нужны дополнительные зависимости. Устанавливаем, если надо:
sudo apt-get install build-essential ^libxcb.* libx11-xcb-dev libglu1-mesa-dev libxrender-dev libfontconfig1-dev
Далее пройти сюда, выбрать нужную версию и в папке single скачать архив с исходниками:
qt-everywhere-src-"ВЕРСИЯ".tar.xz
Следующим пунктом будет скачивание исходников, любыми способами, и распаковкой в конкретную папку(к примеру):
После того, как распаковка закончится, создаем папку выходного каталога скомпилированного Qt:
Переходим в каталог распаковки:
Далее запускаем конфигуратор сборки:
./configure -platform linux-g++ -release -static -fontconfig -opensource -confirm-license -nomake examples -nomake tests -qt-zlib -qt-libpng -qt-libjpeg -prefix /usr/lib/Qt5_st
, где -static — это то, ради чего всё затевалось. Статическая сборка проектов. Остальное можно посмотреть в документации.
И затем выполняем команды сборки и последующей установки Qt в систему:
sudo make sudo make install
Ждем некоторое количество времени, всё зависит от конфигурации ПК, где происходит компиляция.
После компиляции в созданной папке /usr/lib/Qt5_st/bin будет лежать файл qmake, к которому надо указать путь в самой QT (Инструменты-Параметры-Профили QT-Добавить — и выбрать файл qmake из папки /usr/lib/Qt5_st/bin)
Далее надо нажать применить — перейти на вкладку комплекты — нажать добавить, внизу в списке выбрать профиль QT и выбрать созданный на предыдущем шаге профиль. Осталось только нажать применить и ОК. Можно закрыть настройки, и добавить профиль к текущему проекту. Для этого надо нажать CTRL + 5 и добавитьк проекту новый вариант сборки.
И на этом всё, при компиляции проекта на выходе будет единый бинарный файл, включающий в себя все используемые библиотеки Qt.
Building Qt Creator from Git on Ubuntu 22.04
To build Qt Creator on Ubuntu 22.04 follow the steps:
Contents
1. Install build tools
$ sudo apt install build-essential cmake ninja-build git
2. Install all the Ubuntu Qt 6 SDK packages
$ sudo apt install qt6-base-dev qt6-base-private-dev qt6-declarative-dev qt6-declarative-private-dev qt6-tools-dev qt6-tools-private-dev qt6-scxml-dev qt6-documentation-tools libqt6core5compat6-dev qt6-tools-dev-tools qt6-l10n-tools qt6-shader-baker libqt6shadertools6-dev qt6-quick3d-dev qt6-quick3d-dev-tools libqt6svg6-dev libqt6quicktimeline6-dev libqt6serialport6-dev
3. Install LLVM / Clang dependencies
$ sudo apt install clang-15 clangd-15 libclang-15-dev
4. Install Qt Creator dependencies
$ sudo apt install libgl1-mesa-dev libvulkan-dev libxcb-xinput-dev libxcb-xinerama0-dev libxkbcommon-dev libxkbcommon-x11-dev libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xkb1 libxcb-randr0 libxcb-icccm4
5. Get Qt Creator source code
$ git clone --recursive https://code.qt.io/qt-creator/qt-creator.git repo
6. Build Qt Creator
$ cmake -G Ninja -S repo -B build -D CMAKE_BUILD_TYPE=Release $ cmake --build build $ cmake --install build/ --prefix qtcreator-install
Now we’ve got a full build of Qt Creator! 🎉
We can start ./qtcreator-install/bin/qtcreator to open the repo/CMakeLists.txt project and load the build that we’ve currently made 😊
If the CMake configure process is complaining about something, just use apt-file search to locate the package that needs to be installed.