2022-10-04 14:45:47 +00:00
# Ladybird browser build instructions
## Build Prerequisites
2024-07-27 11:30:16 +00:00
Qt6 development packages, FFmpeg, nasm, additional build tools, and a C++23 capable compiler like g++-13 or clang-17 are required.
2023-02-03 11:58:48 +00:00
2024-07-27 11:30:16 +00:00
CMake 3.25 or newer must be available in $PATH.
2024-07-13 20:24:11 +00:00
2024-07-27 11:30:16 +00:00
> [!NOTE]
> In all of the below lists of packages, the Qt6 multimedia package is not needed if your Linux system supports PulseAudio.
2023-11-02 17:53:38 +00:00
2024-06-29 09:45:28 +00:00
---
2024-07-13 20:24:11 +00:00
### Debian/Ubuntu:
```bash
2024-09-30 12:33:08 +00:00
sudo apt install autoconf autoconf-archive automake build-essential ccache cmake curl fonts-liberation2 git libavcodec-dev libavformat-dev libavutil-dev libgl1-mesa-dev nasm ninja-build pkg-config qt6-base-dev qt6-tools-dev-tools qt6-wayland tar unzip zip
2024-07-13 20:24:11 +00:00
```
#### CMake 3.25 or newer:
2024-06-29 09:45:28 +00:00
2024-07-13 20:24:11 +00:00
- Recommendation: Install `CMake 3.25` or newer from [Kitware's apt repository ](https://apt.kitware.com/ ):
2024-06-29 09:45:28 +00:00
2024-07-27 11:30:16 +00:00
> [!NOTE]
> This repository is Ubuntu-only
2024-06-29 09:45:28 +00:00
```bash
2024-07-13 20:24:11 +00:00
# Add Kitware GPG signing key
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
2024-06-29 09:45:28 +00:00
2024-07-13 20:24:11 +00:00
# Optional: Verify the GPG key manually
# Use the key to authorize an entry for apt.kitware.com in apt sources list
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/kitware.list
2024-06-29 09:45:28 +00:00
2024-07-13 20:24:11 +00:00
# Update apt package list and install cmake
sudo apt update -y & & sudo apt install cmake -y
2024-06-29 09:45:28 +00:00
```
2024-07-13 20:24:11 +00:00
#### C++23-capable compiler:
2022-10-04 14:45:47 +00:00
2024-07-13 20:24:11 +00:00
- Recommendation: Install `clang-17` or newer from [LLVM's apt repository ](https://apt.llvm.org/ ):
```bash
# Add LLVM GPG signing key
sudo wget -O /usr/share/keyrings/llvm-snapshot.gpg.key https://apt.llvm.org/llvm-snapshot.gpg.key
2022-10-04 14:45:47 +00:00
2024-07-13 20:24:11 +00:00
# Optional: Verify the GPG key manually
# Use the key to authorize an entry for apt.llvm.org in apt sources list
echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.key] https://apt.llvm.org/$(lsb_release -sc)/ llvm-toolchain-$(lsb_release -sc)-18 main" | sudo tee -a /etc/apt/sources.list.d/llvm.list
2023-02-03 11:58:48 +00:00
2024-07-13 20:24:11 +00:00
# Update apt package list and install clang and associated packages
sudo apt update -y & & sudo apt install clang-18 clangd-18 clang-format-18 clang-tidy-18 lld-18 -y
2023-02-03 11:58:48 +00:00
```
2024-07-13 20:24:11 +00:00
- Alternative: Install gcc-13 or newer from [Ubuntu Toolchain PPA ](https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test ):
```bash
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update & & sudo apt install g++-13 libstdc++-13-dev
2023-02-03 11:58:48 +00:00
```
2024-07-23 01:09:30 +00:00
#### Audio support:
- Recommendation: Install PulseAudio development package:
```bash
sudo apt install libpulse-dev
```
- Alternative: Install Qt6's multimedia package:
```bash
sudo apt install qt6-multimedia-dev
```
2024-07-13 20:24:11 +00:00
### Arch Linux/Manjaro:
2022-10-04 14:45:47 +00:00
```
2024-07-23 01:06:44 +00:00
sudo pacman -S --needed autoconf-archive automake base-devel ccache cmake curl ffmpeg libgl nasm ninja qt6-base qt6-multimedia qt6-tools qt6-wayland ttf-liberation tar unzip zip
2022-10-04 14:45:47 +00:00
```
2024-07-13 20:24:11 +00:00
### Fedora or derivatives:
2022-10-04 14:45:47 +00:00
```
2024-09-19 15:28:42 +00:00
sudo dnf install autoconf-archive automake ccache cmake curl libavcodec-free-devel libavformat-free-devel liberation-sans-fonts libglvnd-devel nasm ninja-build perl-FindBin perl-IPC-Cmd qt6-qtbase-devel qt6-qtmultimedia-devel qt6-qttools-devel qt6-qtwayland-devel tar unzip zip zlib-ng-compat-static
2022-10-04 14:45:47 +00:00
```
2024-07-13 20:24:11 +00:00
### openSUSE:
2023-04-27 18:26:17 +00:00
```
2024-09-09 14:03:15 +00:00
sudo zypper install autoconf-archive automake ccache cmake curl ffmpeg-7-libavcodec-devel ffmpeg-7-libavformat-devel gcc13 gcc13-c++ liberation-fonts libglvnd-devel nasm ninja qt6-base-devel qt6-multimedia-devel qt6-tools-devel qt6-wayland-devel tar unzip zip
2023-04-27 18:26:17 +00:00
```
2024-07-06 19:23:07 +00:00
The build process requires at least python3.7; openSUSE Leap only features Python 3.6 as default, so it is recommendable to install package python311 and create a virtual environment (venv) in this case.
2023-04-27 18:26:17 +00:00
2024-07-13 20:24:11 +00:00
### NixOS or with Nix:
> [!NOTE]
> These steps are out of date, as vcpkg does not work with Nix.
> Please refer to the nixpkgs package for the most up-to-date build instructions.
>
2024-03-16 08:36:09 +00:00
```console
2024-07-10 00:16:38 +00:00
nix develop
2023-12-04 01:13:55 +00:00
# With a custom entrypoint, for example your favorite shell
2024-07-10 00:16:38 +00:00
nix develop --command bash
2022-09-22 11:22:28 +00:00
```
2023-12-04 01:13:55 +00:00
2024-03-16 08:36:09 +00:00
On NixOS or with Nix using your host `nixpkgs` and the legacy `nix-shell` tool:
```console
nix-shell Ladybird
2023-12-04 01:13:55 +00:00
# With a custom entrypoint, for example your favorite shell
2024-03-16 08:36:09 +00:00
nix-shell --command bash Ladybird
2023-09-01 14:30:49 +00:00
```
2022-09-22 11:22:28 +00:00
2024-07-13 20:24:11 +00:00
### macOS:
2022-10-04 14:45:47 +00:00
2024-04-30 13:19:35 +00:00
Xcode 14 versions before 14.3 might crash while building ladybird. Xcode 14.3 or clang from homebrew may be required to successfully build ladybird.
2023-02-03 11:58:48 +00:00
2022-10-04 14:45:47 +00:00
```
xcode-select --install
2024-07-23 01:06:44 +00:00
brew install autoconf autoconf-archive automake ccache cmake ffmpeg nasm ninja pkg-config
2023-10-24 14:35:33 +00:00
```
2024-07-27 11:30:16 +00:00
If you wish to use clang from homebrew instead:
```
brew install llvm
```
2023-10-24 14:35:33 +00:00
If you also plan to use the Qt chrome on macOS:
```
brew install qt
2022-10-04 14:45:47 +00:00
```
2024-07-13 20:24:11 +00:00
### Windows:
2024-10-10 23:32:58 +00:00
WSL2 is the supported way to build Ladybird on Windows. An experimental native build is being setup but does not fully
build.
#### WSL2
2024-07-13 20:24:11 +00:00
- Create a WSL2 environment using one of the Linux distros listed above. Ubuntu or Fedora is recommended.
- Install the required packages for the selected Linux distro in the WSL2 environment.
WSL1 is known to have issues. If you run into problems, please use WSL2.
MinGW/MSYS2 are not supported.
2024-10-10 23:32:58 +00:00
##### Clang-CL (experimental)
> [!NOTE]
> This only gets the cmake to configure. There is still a lot of work to do in terms of getting it to build.
In order to get pkg-config available for the vcpkg install, you can use Chocolatey to install it.
To install Chocolatey, see `https://chocolatey.org/install` .
Then Install pkg-config using chocolatey.
```
choco install pkgconfiglite -y
```
2024-07-13 20:24:11 +00:00
### OpenIndiana:
2023-02-28 09:32:56 +00:00
2023-05-06 14:28:34 +00:00
Note that OpenIndiana's latest GCC port (GCC 11) is too old to build Ladybird, so you need Clang, which is available in the repository.
2023-02-28 09:32:56 +00:00
```
2024-07-23 01:06:44 +00:00
pfexec pkg install clang-17 cmake libglvnd ninja qt6
2023-02-28 09:32:56 +00:00
```
2024-07-13 20:24:11 +00:00
### Haiku:
2023-08-29 15:13:46 +00:00
```
2024-07-23 01:06:44 +00:00
pkgman install cmake cmd:python3 ninja openal_devel qt6_base_devel qt6_multimedia_devel qt6_tools_devel
2023-08-29 15:13:46 +00:00
```
2024-07-13 20:24:11 +00:00
### Android:
2023-09-14 21:59:33 +00:00
On a Unix-like platform, install the prerequisites for that platform and then see the [Android Studio guide ](AndroidStudioConfiguration.md ).
2023-10-24 14:35:33 +00:00
Or, download a version of Gradle >= 8.0.0, and run the ``gradlew`` program in ``Ladybird/Android``
2023-09-14 21:59:33 +00:00
2023-02-03 11:58:48 +00:00
## Build steps
2024-05-31 23:27:20 +00:00
### Using ladybird.sh
2023-02-03 11:58:48 +00:00
2024-05-31 23:27:20 +00:00
The simplest way to build and run ladybird is via the ladybird.sh script:
2022-10-04 14:45:47 +00:00
2023-08-25 11:05:57 +00:00
```bash
2024-05-30 21:06:21 +00:00
# From /path/to/ladybird
2024-05-31 23:27:20 +00:00
./Meta/ladybird.sh run ladybird
2024-07-27 11:30:16 +00:00
```
On macOS, to build using clang from homebrew:
```bash
CC=$(brew --prefix llvm)/bin/clang CXX=$(brew --prefix llvm)/bin/clang++ ./Meta/ladybird.sh run
```
You may also choose to start it in `gdb` using:
```bash
2024-05-31 23:27:20 +00:00
./Meta/ladybird.sh gdb ladybird
2022-10-04 14:45:47 +00:00
```
2024-07-09 14:06:41 +00:00
The above commands will build a Release version of Ladybird. To instead build a Debug version, run the
`Meta/ladybird.sh` script with the value of the `BUILD_PRESET` environment variable set to `Debug` , like this:
```bash
BUILD_PRESET=Debug ./Meta/ladybird.sh run ladybird
```
2024-07-27 11:30:16 +00:00
Note that debug symbols are available in both Release and Debug builds.
### The chromes
Ladybird will be built with one of the following browser chromes (graphical frontends), depending on the platform:
2023-08-25 11:05:57 +00:00
* [AppKit ](https://developer.apple.com/documentation/appkit?language=objc ) - The native chrome on macOS.
2023-10-24 14:35:33 +00:00
* [Qt ](https://doc.qt.io/qt-6/ ) - The chrome used on all other platforms.
2024-07-13 20:24:11 +00:00
* [Android UI ](https://developer.android.com/develop/ui ) - The native chrome on Android.
2023-08-25 11:05:57 +00:00
2023-10-24 14:35:33 +00:00
The Qt chrome is available on platforms where it is not the default as well (except on Android). To build the
Qt chrome, install the Qt dependencies for your platform, and enable the Qt chrome via CMake:
2023-08-25 11:05:57 +00:00
```bash
2024-05-30 21:06:21 +00:00
# From /path/to/ladybird
2024-06-04 21:10:48 +00:00
cmake --preset default -DENABLE_QT=ON
2023-08-25 11:05:57 +00:00
```
2023-10-24 14:35:33 +00:00
To re-disable the Qt chrome, run the above command with `-DENABLE_QT=OFF` .
2024-07-25 18:56:05 +00:00
### Build error messages you may encounter
The section lists out some particular error messages you may run into, and explains how to deal with them.
#### Unable to find a build program corresponding to "Ninja"
2024-10-08 13:04:58 +00:00
This error message is a red herring. We use vcpkg to manage our third-party dependencies, and this error is logged when
something went wrong building those dependencies. The output in your terminal will vary depending on what exactly went
wrong, but it should look something like:
2024-07-25 18:56:05 +00:00
```
2024-10-08 13:04:58 +00:00
error: building skia:x64-linux failed with: BUILD_FAILED
Elapsed time to handle skia:x64-linux: 1.6 s
-- Running vcpkg install - failed
CMake Error at Toolchain/Tarballs/vcpkg/scripts/buildsystems/vcpkg.cmake:899 (message):
vcpkg install failed. See logs for more information:
Build/ladybird/vcpkg-manifest-install.log
Call Stack (most recent call first):
/usr/share/cmake-3.30/Modules/CMakeDetermineSystem.cmake:146 (include)
CMakeLists.txt:15 (project)
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred! See logs for more information:
Build/ladybird/vcpkg-manifest-install.log
2024-07-25 18:56:05 +00:00
```
2024-10-08 13:04:58 +00:00
If the error is not immediately clear from the terminal output, be sure to check `Build/ladybird/vcpkg-manifest-install.log`
for more information.
2024-07-25 18:56:05 +00:00
2023-02-03 11:58:48 +00:00
### Resource files
2024-05-30 21:06:21 +00:00
Ladybird requires resource files from the ladybird/Base/res directory in order to properly load
2024-06-04 21:10:48 +00:00
icons, fonts, and other theming information. These files are copied into the build directory by
special CMake rules. The expected location of resource files can be tweaked by packagers using
the standard CMAKE_INSTALL_DATADIR variable. CMAKE_INSTALL_DATADIR is expected to be a path relative
to CMAKE_INSTALL_PREFIX. If it is not, things will break.
2023-02-03 11:58:48 +00:00
### Custom CMake build directory
2024-06-04 21:10:48 +00:00
The script Meta/ladybird.sh and the default preset in CMakePresets.json both define a build directory of
`Build/ladybird` . For distribution purposes, or when building multiple configurations, it may be useful to create a custom
CMake build directory.
2023-02-03 11:58:48 +00:00
The install rules in Ladybird/cmake/InstallRules.cmake define which binaries and libraries will be
installed into the configured CMAKE_PREFIX_PATH or path passed to ``cmake --install``.
2024-05-31 23:27:20 +00:00
Note that when using a custom build directory rather than Meta/ladybird.sh, the user may need to provide
2024-05-17 13:40:40 +00:00
a suitable C++ compiler (g++ >= 13, clang >= 14, Apple Clang >= 14.3) via the CMAKE_CXX_COMPILER and
2023-02-03 11:58:48 +00:00
CMAKE_C_COMPILER cmake options.
2022-10-04 14:45:47 +00:00
```
2024-06-04 21:10:48 +00:00
cmake -GNinja -B MyBuildDir
2023-02-03 11:58:48 +00:00
# optionally, add -DCMAKE_CXX_COMPILER=<suitable compiler> -DCMAKE_C_COMPILER=<matching c compiler>
2024-06-04 21:10:48 +00:00
cmake --build MyBuildDir
ninja -C MyBuildDir run-ladybird
2022-10-04 14:45:47 +00:00
```
2024-06-04 21:10:48 +00:00
### Running manually
The Meta/ladybird.sh script will execute the `run-ladybird` and `debug-ladybird` custom targets.
If you don't want to use the ladybird.sh script to run the application, you can run the following commands:
2022-12-23 23:47:02 +00:00
To automatically run in gdb:
```
2024-06-04 21:10:48 +00:00
ninja -C Build/ladybird debug-ladybird
2022-12-23 23:47:02 +00:00
```
2022-10-04 14:45:47 +00:00
2023-11-17 16:20:47 +00:00
To run without ninja rule on non-macOS systems:
2022-10-04 14:45:47 +00:00
```
2023-11-17 16:20:47 +00:00
./Build/ladybird/bin/Ladybird
```
To run without ninja rule on macOS:
```
open -W --stdout $(tty) --stderr $(tty) ./Build/ladybird/bin/Ladybird.app
# Or to launch with arguments:
open -W --stdout $(tty) --stderr $(tty) ./Build/ladybird/bin/Ladybird.app --args https://ladybird.dev
2022-10-04 14:45:47 +00:00
```
2024-04-08 19:15:00 +00:00
### Experimental GN build
There is an experimental GN build for Ladybird. It is not officially supported, but it is kept up to date on a best-effort
basis by interested contributors. See the [GN build instructions ](../Meta/gn/README.md ) for more information.
In general, the GN build organizes ninja rules in a more compact way than the CMake build, and it may be faster on some systems.
GN also allows building host and cross-targets in the same build directory, which is useful for managing dependencies on host tools when
cross-compiling to other platforms.
2023-07-06 10:42:24 +00:00
### Debugging with CLion
2024-06-04 21:10:48 +00:00
Ladybird should be built with debug symbols first. This can be done by adding `-DCMAKE_BUILD_TYPE=Debug` to the cmake command line,
or selecting the Build Type Debug in the CLion CMake profile.
2023-07-06 10:42:24 +00:00
2024-06-04 21:10:48 +00:00
After running Ladybird as suggested above with `./Meta/ladybird.sh run ladybird` , you can now in CLion use Run -> Attach to Process to connect. If debugging layout or rendering issues, filter the listing that opens for `WebContent` and attach to that.
2023-07-06 10:42:24 +00:00
Now breakpoints, stepping and variable inspection will work.
2024-06-30 02:06:23 +00:00
### Debugging with Xcode or Instruments on macOS
2023-03-26 16:13:07 +00:00
2024-06-30 02:06:23 +00:00
If all you want to do is use Instruments, then an Xcode project is not required.
Simply run the `ladybird.sh` script as normal, and then make sure to codesign the Ladybird binary with the proper entitlements to allow Instruments to attach to it.
```
./Meta/ladybird.sh build
ninja -C build/ladybird apply-debug-entitlements
# or
codesign -s - -v -f --entitlements Meta/debug.plist Build/ladybird/bin/Ladybird.app
```
Now you can open the Instruments app and point it to the Ladybird app bundle.
If you want to use Xcode itself for debugging, you will need to generate an Xcode project.
2024-05-31 23:27:20 +00:00
The `ladybird.sh` build script does not know how to generate Xcode projects, so creating the project must be done manually.
2023-03-26 16:13:07 +00:00
```
2024-06-03 21:46:00 +00:00
cmake -GXcode -B Build/ladybird
2023-03-26 16:13:07 +00:00
```
2023-05-06 14:28:34 +00:00
After generating an Xcode project into the specified build directory, you can open `ladybird.xcodeproj` in Xcode. The project has a ton of targets, many of which are generated code.
2023-03-26 16:13:07 +00:00
The only target that needs a scheme is the ladybird app bundle.
2023-02-28 09:32:56 +00:00
### Building on OpenIndiana
OpenIndiana needs some extra environment variables set to make sure it finds all the executables
and directories it needs for the build to work. The cmake files are in a non-standard path that
contains the Qt version (replace 6.2 with the Qt version you have installed) and you need to tell
it to use clang and clang++, or it will use gcc and g++ from GCC 10 which is currently the default
to build packages on OpenIndiana.
When running Ladybird, make sure that XDG_RUNTIME_DIR is set, or it will immediately crash as it
doesn't find a writable directory for its sockets.
```
2024-06-03 21:46:00 +00:00
CMAKE_PREFIX_PATH=/usr/lib/qt/6.2/lib/amd64/cmake cmake -GNinja -B Build/ladybird -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++
2023-02-28 09:32:56 +00:00
cmake --build Build/ladybird
XDG_RUNTIME_DIR=/var/tmp ninja -C Build/ladybird run
```