Skip to content

Set up developer environment

Peter Jonas edited this page Dec 7, 2023 · 11 revisions

Summary

  1. Running the commands in this guide
  2. Install a package manager
  3. Install CMake and Git
  4. Set up advanced developer environment (optional)

Running the commands in this guide

We recommend building on the Intel/AMD 64-bit (x86_64) architecture, but we do support Compiling on Macs with Apple Silicon.

Other architectures should work but Qt does not provide binaries for them so you'll need to compile Qt yourself or install it from a third party (e.g. your Linux distribution).

Linux and macOS

Use your terminal of choice. The built-in Terminal application is fine.

Windows

Use PowerShell to start with. Later, after you've installed Git, consider using Git Bash instead of PowerShell (see Set up advanced developer environment (optional) below).

CMD (Command Prompt) will usually work but some commands require a slightly different syntax.

Please do not use WSL or WSL2 (Windows Subsystem for Linux) as compiling in that environment would create Linux binaries rather than Windows executables.

Install a package manager

Having a package manager enables you to install software quickly via the command line.

Linux

Congratulations, you already have a package manager! Use the following command to find out what it is called:

which apt yum dnf pacman emerge zypper | xargs -n1 basename

macOS

Please install one of these package managers:

Windows

Please install one of these package managers:

  • Chocolatey (choco) - recommended for most users
  • Scoop (scoop) - recommended for users who lack administrator privileges (but you'll need an admin to install it for you)

If you picked Chocolatey, it is recommended that you install gsudo (sudo) to enable the choco command to be used from within non-Admin prompts:

# Once from an Administrator prompt:
choco install gsudo

# In future, from non-Admin prompts:
sudo choco install [program]  # spawns UAC dialog to request permission

Scoop can be used from non-Admin prompts by default, but you might want to install gsudo anyway for use with other commands that require administrator privileges.

scoop install gsudo

Install CMake and Git

Use the command(s) corresponding to your package manager.

macOS

brew install cmake git
sudo port install cmake git

Windows

# Chocolatey (Admin prompt or sudo required)
choco install cmake --installargs ADD_CMAKE_TO_PATH=System
choco install git

# others
scoop install cmake git

Linux

sudo apt install cmake git
sudo dnf install cmake git
sudo pacman -S cmake git

Older distributions may not provide a recent enough version of CMake. Check near the top of MuseScore's CMakeLists.txt for the minimum required version, then run:

cmake --version

If your distribution's version of CMake is too old, try installing it via Python's package manager pip instead. Make sure you remove the distribution version first.

# Remove outdated distribution CMake
sudo apt remove --purge cmake
sudo dnf erase cmake

# Install pip for your distribution
sudo apt install python3-pip
sudo dnf install python3-pip

# Install latest CMake from pip
pip3 install wheel setuptools # need these first to install binary packages like CMake
pip3 install cmake

The CMake PyPI package (the one installed via pip) is an official method of installing CMake as documented on the CMake downloads page. However, distribution maintainers may be forced to use their distribution's CMake when building a MuseScore package, so the existence of the PyPI CMake is not a valid reason to update our minimum required version prematurely (but there may be other reasons for doing so that are valid).

Set up advanced developer environment (optional)

This section is not required to compile and run MuseScore. However, it may be required if you want to run scripts in the repository that are supplementary to the build, such as scripts to generate assets, templates, translations, or other resources. It will also give you a much nicer experience on the command line!

All platforms

On all platforms, if you need to install a Python program or module (e.g. requests), use your regular package manager to install Python's own package manager pip, then use pip to install the program/module. Don't use your regular package manager to install the program/module because it may not give you the latest version, and this method of installation won't be tested as thoroughly as via pip.

# Don't do this:
sudo apt install python3-requests  # installs outdated version

# Do this instead:
sudo apt install python3-pip
pip3 install requests  # notice no 'sudo' and pip name ends with '3' to distinguish from the Python 2 version

Do the same in other languages that have package managers, such as Rust (cargo), Node (npm), and Ruby (gem).

Linux

Congratulations, you already have an advanced developer environment!

macOS

For licensing reasons, macOS only provides Bash version 3 by default. Version 3 is ancient, so use these commands to install a more recent version:

brew install bash  # install newer Bash
which bash | sudo tee -a /etc/shells  # allow it to run as login shell in Terminal
chsh -s "$(which bash)"  # optional: use it as your default login shell in Terminal

When writing shell scripts for macOS, it's a good idea to make the script check the Bash version before doing anything else.

#!/usr/bin/env bash

((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; }

# Commands from this point onwards can safely use modern Bash syntax

As well as an outdated Bash, macOS also uses the BSD variants of the standard Unix tools (ls, find, grep, sed, etc.) rather than the more popular GNU variants used by Linux and Git Bash. The BSD and GNU variants are very similar, but syntax and features do vary slightly between them, so you should bear this in mind if you need to write shell scripts that are portable across platforms. It is possible to install the GNU variants of Unix tools on macOS but it is probably best to not do this because you'll end up writing shell scripts that won't work properly without them.

Windows

Now that you have installed Git, you also have access to Git Bash. This is a full Bash shell plus a core set of familiar Unix tools (ls, find, grep, sed, etc.) all compiled to work natively on Windows. Unless stated otherwise, Git Bash can be used for all subsequent commands instead of PowerShell or CMD.

You can access Git Bash from the Start Menu and it will launch inside MinTTY, but we recommend using it inside Windows Terminal instead. Windows Terminal is installed by default in Windows 11. Windows 10 users can install for free it from the Microsoft Store.

Launch Windows Terminal and open its Settings. Add a new profile with the following information:

  • Name: Bash
  • Starting directory: %USERPROFILE%

And if you installed Git via Chocolatey or the EXE installer:

  • Command line: "%ProgramFiles%\Git\bin\bash.exe" -i
  • Icon: %ProgramFiles%\Git\mingw64\share\git\git-for-windows.ico

Or if you installed Git via Scoop:

  • Command line: "%UserProfile%\scoop\apps\git\current\usr\bin\bash.exe" -i
  • Icon: %UserProfile%\scoop\apps\git\current\mingw64\share\git\git-for-windows.ico

Git Bash will now appear in the dropdown list of profiles within Windows Terminal. You can optionally make it the default profile via Windows Terminal's Settings > Startup.

Testing

Translation

Compilation

  1. Set up developer environment
  2. Install Qt and Qt Creator
  3. Get MuseScore's source code
  4. Install dependencies
  5. Compile on the command line
  6. Compile in Qt Creator

Beyond compiling

  1. Find your way around the code
  2. Submit a Pull Request
  3. Fix the CI checks

Misc. development

Architecture general

Audio

Engraving

Extensions

Google Summer of Code

References

Clone this wiki locally