Qt Creator 4.x compile instructions

עודכן לפני 4 שנים

Introduction

This page is a walkthrough for setting up MuseScore debugging with Qt Creator 4.x. It assumes you have completed all steps from Compile instructions (Windows - MinGW) - Git before starting.

Configuration

  1. Once you setup everything above, you can open Qt Creator, either by typing start qtcreator from within a command prompt started as above, or by creating a separate batch file with start qtcreator as the last command.
  2. Go to FileOpen File or Project....
  3. Choose CMakeLists.txt file type and open the file CMakeLists.txt from your source directory. This will lead to a screen to start configuring the project.

Build Location

Make sure to change the build directory to be build.qtc directly under the directory of your git clone. Please make sure the name of the build directory does not contain spaces.

In the screenshot, the project was cloned into MuseScore_git, so this results in the following setting:

01_configure.png

Click on Configure Project to continue.

Build Settings

Navigate to ProjectsBuild & RunBuild to adjust the following CMake settings:

BUILD_64
OFF for 32-bit builds
CMAKE_INSTALL_PREFIX
../win32install (use ..\win64install for 64-bit builds, possible with Qt 5.12). Seems for master branch it is now one lever higher, so drop the ../.
CMAKE_BUILD_TYPE
DEBUG (Prior to cd19c84 for master and cba1df2 for 2.2 mind the uppercasing!, later builds are fine using the default value of Debug)

Additional changes for older versions before 9caf157 (5th January 2018)

02_Build_Settings.png

Click on Apply Configuration Changes
CMake will automatically run. You'll see a spinner over the CMake settings while it does.
Note: You might get a warning from CMake about QT_QMAKE_EXECUTABLE not being used.

Build Settings: selecting targets

Scroll a bit down to the Build Steps area. Expand the Details of that area and select the lrelease target.

04_Build_Settings_Steps.png

Use the button just below this list to add another Build step:

05_Build_Settings_Add_Step.png

And set it to the install target:

06_Build_Settings_Install_Step.png

Run Settings

In the left column of the screen, click on Run to switch to the Run Settings. Where the Run configuration is set, choose to Add a Custom Executable.

07_Run_Settings_Run.png

Finally, set the Executable value to %{sourceDir}\win32install\bin\MuseScore3.exe
(use win64install for 64-bit builds and MuseScore3.exe when building MuseScore 3, and MuseScore4.exe when building MuseScore 4)

08_Run_Settings_Run_exe.png

Before Debugging

These are some of the problems that you may or may not face while completing the next section.

  1. The compile time for debug build will vary from 10 minutes (8 core system) to 1 hour (single core) depending on the number of cores that your system has.

  2. One should disable the ClangCodeModel in the top bar under Help > Plugins > C++ otherwise you may get many C++ errors/issues. These don't prevent a build but may result in missing important warnings and real errors.

  3. After step 2, if you get an error stating that libgcc_s_seh-1.dll not found under your mingw root directory's bin, then you're most probably building a 32-bit version, then you have to disable BUILD_64 from your building process. To do so go to Projects in the left hand side. Under Build & Run, click on Build. Where you previously set CMAKE_EXECUTABLE_PATH, there will also be a checkbox for BUILD_64. Disable that and then follow the instructions in the next section.

Most likely you will be able to compile successfully.

Debug

To compile the debug build and start debugging you can do either one of the following:

  • Go to DebugStart debuggingStart debugging
  • Click the debug icon. (green arrow with bug on top of it in the bottom left of Qt Creator)
  • Press F5

Parallel Build

If you have a multi-core/threading processor, compilation can be sped up significantly by allow Qt Creator to launch multiple parallel build processes. To achieve this, you can set -j%NUMBER_OF_PROCESSORS% in the Tool arguments for both the Build Steps as the Deployment Steps.
On a quad-core hyperthreading processor you could go up to -j8 to maximize the processor load. It might be wise to set the number to be one lower than your maximal number of processes, allowing you to perform another program while the build is running.

resfile.o Error

If you are facing errors which mention resfile.o in description like here (see https://musescore.org/en/node/151481), the following command line hack should help you.
The issue relates to incorrectly initialized windres tool and its path. To correctly initialize the related cmake data, please do the following:

  1. Close QtCreator
  2. Go to MuseScore repo
  3. mingw32-make.exe -f Makefile.mingw debug
  4. mingw32-make.exe -f Makefile.mingw installdebug
  5. Open Qt creator and debug MuseScore