Skip to content

Compile in Qt Creator

Peter Jonas edited this page Feb 2, 2023 · 22 revisions

Summary

  1. Open the project
  2. Configure the project
  3. Change Project install settings
    1. Edit Build settings
    2. Edit Run settings
  4. Start Debugging

You must have followed the steps to install Qt and Qt Creator and get MuseScore's source code. You are also encouraged to compile on the command line before you attempt to compile in Qt Creator or other IDEs.

Open the project

Launch Qt Creator. From the File menu or Welcome screen, use the option to open an existing project. (Don't use the option to create a new project.)

Open the CMakeLists.txt file in the root of MuseScore's code directory.

Configure the project

You will be asked to choose a build kit. You have one build kit for each version and compiler of Qt you have installed.

Pick any build kit and enable at least one build configuration for it. The options are:

Configuration Description
Debug Special symbols are included in the compiled executable to enable advanced debugging techniques (e.g. to set breakpoints, pause the running application, step through code line-by-line, monitor the value of code variables, etc.).
Release All debug symbols are removed to create a smaller executable that runs faster on end-users' machines.
RelWithDebInfo A compromise between Release and Debug that includes some symbols for limited debugging. Use this option if you find Debug builds are too slow on your machine.
MinSizeRel A release build with further optimizations applied that may sacrifice some performance in return for a smaller executable size.

As a developer using an IDE, it only really makes sense to use Debug or RelWithDebInfo.

Tip: If you want to work on the Release configuration for deployment to end-users then you should compile on the command line using the same method as the CI scripts.

Change Project install settings

By default, Qt Creator will compile the project but not install it. This gives you a program that basically works, but it will be missing certain features that rely on external resources such as fonts, sounds, and score templates for the New Score Wizard. If you want access to these things (recommended) then it is necessary to install the program.

Once the initial configuration is complete, switch to the Projects screen. The Build & Run section on the left should list available build kits. Enabled kits look like this:

  • 🖥️ Desktop Qt [version] [compiler]
    • 🔨 Build
    • ▶ Run

Edit Build settings

From the Projects screen, click Build under your chosen kit. This takes you to the Build Settings page for that kit.

In the CMake section on the right:

  1. Select the Current Configuration tab.
  2. Type "install" in the Filter box.
  3. Locate the variable CMAKE_INSTALL_PREFIX.

The default value of CMAKE_INSTALL_PREFIX is /usr/local on Linux and macOS, or C:\Program Files on Windows. However, we don't want to install to those locations, and you can't anyway without root/Administrator privileges. Instead, we want to install to a new directory called install located directly inside the build directory.

To change the installation directory:

  1. Locate where Build directory is displayed higher up the screen.
  2. Right-click on the build directory path and choose Select All, then right-click again and choose Copy.
  3. Double-click inside the value for CMAKE_INSTALL_PREFIX and delete the current value.
  4. Paste the build directory as the new value in CMAKE_INSTALL_PREFIX and type /install after it.
  5. Press the Return key to confirm the new value, then click Run CMake.

Edit Run settings

From the Projects screen, click Run under your chosen kit. This takes you to the Run Settings page for that kit.

In the Deployment section on the right:

  1. Click Add Deploy Step > CMake Build.
  2. Next to Targets, ensure the install target is selected.

In the Run section:

  1. Find Run configuration and click Add....
  2. Choose Custom Executable and click Create.
  3. Click Rename
  4. Type "MuseScore (installed)" as the new name and click OK.

Now enter the following information:

Executable:

  • Linux: %{buildDir}/install/bin/mscore
  • macOS: %{buildDir}/install/mscore.app/Contents/MacOS/mscore
  • Windows: %{buildDir}/install/bin/MuseScore4.exe

Command line arguments: (leave blank or add any valid arguments, such as -F)

Working directory: %{sourceDir}

Start Debugging

To compile the program, click the large green arrow with the bug symbol in the bottom left of the screen. Click the "Compile Output" tab at the bottom of the screen to follow the progress of the build and check for errors if it fails.

If the code compiles successfully then MuseScore will launch automatically as soon as the build is complete. Click the "Application Output" tab at the bottom of the screen to view MuseScore's command line output and debug messages.

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