Add macOS ARM support details to README

This commit is contained in:
jingjing_tang 2025-09-09 15:46:44 +08:00 committed by GitHub
parent 6b4afa0f87
commit 8b96c15440
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 52 additions and 0 deletions

52
README
View File

@ -1,3 +1,55 @@
Branch Name: qt5.12.3/universal
Maintainer: shinyTang
Source Repository: https://github.com/qt/qt5
Purpose: The official Qt 5.12.3 release lacks support for compilation on macOS ARM (Apple Silicon) architectures. This branch contains modifications to Qt 5.12.3 to add native support for macOS ARM64.
========
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:
1. qtbase Module:
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.
Added necessary includes (e.g., #include <CoreGraphics/CGColorSpace.h>) for the macOS graphics stack.
2. qtmultimedia Module:
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.
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.
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.
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.
2.Create a Merged libxcb Library:
On each machine, locate the libxcb.dylib file you installed (typically in /usr/local/lib or /opt/homebrew/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
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.
3.Execute the Build Script: Run the script to start the compilation process for both architectures and merge the Qt libraries.
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 content follows -->
HOW TO BUILD QT5
================