Revise README for Qt 5.12.3 Universal build

Updated README to reflect changes for Qt 5.12.3 Universal build on macOS ARM and Intel architectures, including purpose, modifications, and build instructions.
This commit is contained in:
jingjing_tang 2025-09-15 14:57:46 +08:00 committed by GitHub
parent 16a49f9aed
commit c29f971021
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 119 additions and 136 deletions

255
README
View File

@ -1,186 +1,169 @@
Source Repository: https://github.com/qt/qt5
# Qt 5.12.3 Universal (Apple Silicon/macOS)
Purpose: The official Qt 5.12.3 release lacks support for compilation on macOS ARM (Apple Silicon) architectures. This branch provides a patch for Qt 5.12.3 that enables compilation and native execution on macOS ARM64 systems.
**Source Repository:** [https://github.com/qt/qt5](https://github.com/qt/qt5)
================
---
Branch Modifications (Differences):
This branch is based on the Qt dev branch at commit 8337e20fadddf, which corresponds to the Qt 5.12.3 release state. The following modifications have been applied:
## Purpose
1. qtbase Module:
> The official Qt 5.12.3 release lacks support for compilation on macOS ARM (Apple Silicon) architectures.
> This branch provides a patch for Qt 5.12.3 that enables compilation and native execution for both Intel (x86_64) and ARM (arm64) architectures, as well as legacy 32-bit Intel (i386).
Fixed a missing #include <math.h> in libpng to resolve compilation errors.
---
Removed the #error "32-bit builds are not supported" directives and related code in Cocoa platform plugins to enable 32-bit (i386) compilation support on macOS.
## 🚩 **Branch Modifications (Differences)**
Added necessary includes (e.g., #include <CoreGraphics/CGColorSpace.h>) for the macOS graphics stack.
This branch is based on the Qt dev branch at commit `8337e20fadddf` (Qt 5.12.3 release).
**Key changes:**
2. qtmultimedia Module:
### 1. `qtbase` Module:
- **Fixed:** Missing `#include <math.h>` in libpng to resolve compilation errors.
- **Removed:** `#error "32-bit builds are not supported"` directives and related code in Cocoa platform plugins to enable 32-bit (i386) compilation support on macOS.
- **Added:** Necessary includes (e.g., `#include <CoreGraphics/CGColorSpace.h>`) for the macOS graphics stack.
Refactored code in the AVFoundation plugin to replace deprecated C++98 functional utilities (std::binary_function, std::unary_function, std::not2) with modern C++11/14 equivalents (lambda functions). This ensures compatibility with modern compilers enforcing the C++17 standard.
### 2. `qtmultimedia` Module:
- **Refactored:** AVFoundation plugin code replacing deprecated C++98 functional utilities (`std::binary_function`, `std::unary_function`, `std::not2`) with modern C++11/14 equivalents (lambda functions, etc.).
Summary: These changes ensure Qt 5.12.3 can be compiled for both Intel (x86_64) and ARM (arm64) architectures on macOS, as well as for the legacy 32-bit Intel (i386) target, creating a more universal binary build.
**Summary:**
These changes ensure Qt 5.12.3 can be compiled for both Intel (x86_64) and ARM (arm64) architectures on macOS, as well as for the legacy 32-bit Intel (i386) target, creating a more universal build.
================
---
Build Instructions:
## 🛠️ **Build Instructions**
This project uses the build_opensource.sh script to compile Qt libraries for both x86_64 and ARM64 architectures, subsequently merging them into a single Universal 2 (universal) binary.
This project uses the `build_opensource.sh` script to compile Qt libraries for both x86_64 and ARM64 architectures, then merges them into a single Universal 2 binary.
Building Universal Libraries (macOS)
1.Prerequisite - Install Identical libxcb: Before running the build script, you must install the exact same version of the libxcb library on both your x86_64 (Intel) and ARM64 (Apple Silicon) machines.
### Building Universal Libraries (macOS)
2.Create a Merged libxcb Library:
1. **Prerequisite Install Identical `libxcb`:**
Before running the build script, install the **same version** of the `libxcb` library on both your x86_64 (Intel) and ARM64 (Apple Silicon) machines.
On each machine, locate the libxcb.dylib file you installed (typically in /usr/local/lib or /opt/homebrew/lib).
2. **Create a Merged `libxcb` Library:**
- On each machine, locate the `libxcb.dylib` file (usually in `/usr/local/lib` or `/opt/homebrew/lib`).
- Use the `lipo` tool to merge:
```sh
lipo -create /path/on/x86_machine/libxcb.dylib /path/on/arm_machine/libxcb.dylib -output ./lib/libxcb.dylib
```
- Replace the system library: Copy the universal `./lib/libxcb.dylib` and overwrite the existing `libxcb.dylib` in your library directory (e.g., `/usr/local/lib`).
Use the lipo tool to merge the two architecture-specific libraries into one universal library:
- lipo -create /path/on/x86_machine/libxcb.dylib /path/on/arm_machine/libxcb.dylib -output ./lib/libxcb.dylib
3. **Execute the Build Script:**
```sh
cd qt5.12.3_universal
bash build_opensource.sh
```
Replace the System Library: Copy the newly created universal ./lib/libxcb.dylib file and overwrite the existing libxcb.dylib in the library directory on your primary build machine (e.g., /usr/local/lib/). This step is crucial for the universal Qt build to link correctly.
### Building a Single Architecture
3.Execute the Build Script: Run the script to start the compilation process for both architectures and merge the Qt libraries.
If you **do not need** a universal library, you can modify the `build_opensource.sh` script to compile for only one architecture (either x86_64 or arm64).
Edit the script to comment out or remove the lines for the other architecture.
cd qt5.12.3_universal
bash build_opoensource.sh
---
Building a Single Architecture
If you do not require a universal library, you can modify the build_opensource.sh script to compile for only one architecture (either x86_64 or arm64). Edit the script to comment out or remove the build commands for the architecture you don't need.
##
============================================================
## Original Qt README
### HOW TO BUILD QT5
================================================================================================================
<!-- Original Qt README content follows -->
HOW TO BUILD QT5
================
#### Synopsis
##### System requirements
- Perl 5.8 or later
- Python 2.7 or later
- C++ compiler supporting the C++11 standard
Synopsis
========
For other platform-specific requirements, see ["Setting up your machine"](http://wiki.qt.io/Get_The_Source).
System requirements
------------------
##### Licensing
- Perl 5.8 or later
- Python 2.7 or later
- C++ compiler supporting the C++11 standard
- Opensource users:
`<license> = -opensource`
- Commercial users:
`<license> = -commercial`
For other platform specific requirements,
please see section "Setting up your machine" on:
http://wiki.qt.io/Get_The_Source
##### Linux, Mac
```sh
cd <path>/<source_package>
./configure -prefix $PWD/qtbase <license> -nomake tests
make -j 4
```
Licensing:
----------
##### Windows
Open a command prompt.
Ensure the following tools are in your path:
- Supported compiler (Visual Studio 2012+, MinGW-builds gcc 4.9+)
- Perl 5.12+ [ActivePerl](http://www.activestate.com/activeperl/)
- Python 2.7+ [ActivePython](http://www.activestate.com/activepython/)
- Ruby 1.9.3+ [RubyInstaller](http://rubyinstaller.org/)
Opensource users:
```bat
cd <path>\<source_package>
configure -prefix %CD%\qtbase <license> -nomake tests
nmake // jom // mingw32-make
```
<license> = -opensource
To accelerate qmake bootstrap with MSVC, use `-make-tool jom` or add `/MP` to the CL environment variable.
Commercial users:
---
<license> = -commercial
### Build Process
Linux, Mac:
-----------
A typical configure & make build process is used.
cd <path>/<source_package>
./configure -prefix $PWD/qtbase <license> -nomake tests
make -j 4
#### Some relevant configure options:
Windows:
--------
- `-release` Compile Qt with debugging off
- `-debug` Compile Qt with debugging on
- `-nomake tests` Disable building of tests
- `-nomake examples` Disable building of examples
- `-confirm-license` Automatically acknowledge the LGPL 2.1 license
Open a command prompt.
Ensure that the following tools can be found in the path:
* Supported compiler (Visual Studio 2012 or later,
MinGW-builds gcc 4.9 or later)
* Perl version 5.12 or later [http://www.activestate.com/activeperl/]
* Python version 2.7 or later [http://www.activestate.com/activepython/]
* Ruby version 1.9.3 or later [http://rubyinstaller.org/]
**Example for release build:**
```sh
./configure -prefix $PWD/qtbase <license>
make -j4
```
cd <path>\<source_package>
configure -prefix %CD%\qtbase <license> -nomake tests
nmake // jom // mingw32-make
**Example for developer build:**
```sh
./configure -developer-build <license>
make -j4
```
To accelerate the bootstrap of qmake with MSVC, it may be useful to pass
"-make-tool jom" on the configure command line. If you do not use jom,
adding "/MP" to the CL environment variable is a good idea.
See output of `./configure -help` for more options.
More details follow.
You can build selected modules with their dependencies:
`make module-<foo>` (e.g., `make module-qtdeclarative`)
Build!
======
---
A typical `configure; make' build process is used.
### Hints
Some relevant configure options (see configure -help):
The submodule repository **qtrepotools** contains useful scripts for developers and release engineers.
Consider adding `qtrepotools/bin` to your PATH.
-release Compile and link Qt with debugging turned off.
-debug Compile and link Qt with debugging turned on.
-nomake tests Disable building of tests to speed up compilation
-nomake examples Disable building of examples to speed up compilation
-confirm-license Automatically acknowledge the LGPL 2.1 license.
---
Example for a release build:
(adjust the `-jN' parameter as appropriate for your system)
### Building Qt5 from git
./configure -prefix $PWD/qtbase <license>
make -j4
See [Building_Qt_5_from_Git](http://wiki.qt.io/Building_Qt_5_from_Git) and README.git for more info.
See [Qt_5 reference platforms](http://wiki.qt.io/Qt_5).
Example for a developer build:
(enables more autotests, builds debug version of libraries, ...)
---
./configure -developer-build <license>
make -j4
### Documentation
See output of `./configure -help' for documentation on various options to
configure.
After configuring and compiling Qt, build docs with:
```sh
make docs
```
Install with:
```sh
make install_docs
```
Docs are installed in `$QT_INSTALL_DOCS`.
`qmake -query` will list the path.
The above examples will build whatever Qt5 modules have been enabled by
default in the build system.
It is possible to build selected modules with their dependencies by doing
a `make module-<foo>'. For example, to build only qtdeclarative,
and the modules it depends on:
./configure -prefix $PWD/qtbase <license>
make -j4 module-qtdeclarative
This can save a lot of time if you are only interested in a subset of Qt5.
Hints
=====
The submodule repository qtrepotools contains useful scripts for
developers and release engineers. Consider adding qtrepotools/bin
to your PATH environment variable to access them.
The qt5_tool in qtrepotools has some more features which may be of interest.
Try `qt5_tool --help'.
Building Qt5 from git
=====================
See http://wiki.qt.io/Building_Qt_5_from_Git and README.git
for more information.
See http://wiki.qt.io/Qt_5 for the reference platforms.
Documentation
=============
After configuring and compiling Qt, building the documentation is possible by running
"make docs".
After having built the documentation, you need to install it with the following
command:
make install_docs
The documentation is installed in the path set to $QT_INSTALL_DOCS.
Running "qmake -query" will list the value of QT_INSTALL_DOCS.
Information about Qt 5's documentation is located in qtbase/doc/README
or in the following page: http://wiki.qt.io/Qt5DocumentationProject
Note: Building the documentation is only tested on desktop platforms.
Further info:
- `qtbase/doc/README`
- [Qt5 Documentation Project](http://wiki.qt.io