Compilation of MuseScore with Visual Studio Community (MSVC) Release

• Aug 13, 2018 - 10:07

We are pleased to announce a big step forward in compilation under Visual Studio and MSVC respectively. Compilation under Visual Studio Community is now available and fully supported.
Frame2.png

Why do we need it?

MuseScore 3.0 is based on the latest Qt version. Unfortunately, QtWebKit which is used for MuseScore Connect is not presented in QT since version 5.4. So we migrated from QtWebKit (QWebView in particular) to QtWebEngine. Unfortunately, QtWebEngine team doesn’t maintain libs for MinGW due to the difficulties in supporting Chromium with the toolchain (https://bugreports.qt.io/browse/QTBUG-42725). So we implemented MSVC compilation for MuseScore to allow using MuseScore Connect on Windows.

Pros and cons

Visual Studio Community is free IDE software which can be a real alternative to the QtCreator.

MSVC compilation is faster than MinGW compilation (about 23% faster). Moreover, the most significant improvement is the incredibly faster linkage, so changing the code in Visual Studio and starting debugger takes few seconds comparing to more than a minute in QtCreator.

We are using AppVeyor CI to build and deploy Windows packages. It is free for open source projects but doesn’t allow several parallel jobs, so we had to limit building MuseScore only with MSVC, in particular, using Visual Studio 2017 (MSVC 15).

Note, QtWebEngine is disabled under MinGW compilation. You can still keep working in QtCreator with MinGW compiler. The core team plan to support full compatibility with mingw compiler for half a year and then drop it, except if someone in the community is committed to supporting it.

Try now

Check out the instruction and build MuseScore with Visual Studio https://musescore.org/en/handbook/developers-handbook/compilation/compi….

Acknowledgements

We thank afprado for great work done to start this significant migration to MSVC. His huge contribution allows us to get things done brick by brick. We also want to thank Jojo for thorough testing the instructions and big input in fixing annoying warnings.

Help us to make MuseScore better

Compilation on MSVC still shows a lot of warnings which are important and show real issues. Some warnings relate to third-party components which we won’t fix, but some of them are about real issues in the MuseScore code. Feel free to submit pull requests with the fixes.

Let's make MuseScore number one together!


Comments

And here's my PR to fix many of these warnings: https://github.com/musescore/MuseScore/pull/3858
In 0e7cd23 we already disabled warnings for thirdparty/poppler

The speed up in linkage is not due to using Visual Studio v0.s Qt Creator (which both are 'just' IDEs), but due to ues the MSVC linker rather than the MinGW one. Similar for the speedup in compile (which BTW one commit if my PR speeds up even more).

What I'm missing currently is the ability to continue using Qt Creator (but with the MSVC toolchain), should be possible, shouldn't it?

A possible next step would be 64-bit builds ;-)

Good job everyone! 👍 I'm curious to see if this will lower the barrier to contribute, and grow the contributor community further.

In reply to by Thomas

It does mean that a non-free tool (MSVC) will now be required to work on Free Software (MuseScore). That being said, this applies only to people on a non-free OS anyway, and those so concerned can use GNU/Linux (if needed, in a VM) to work on MuseScore using Free tools, so I don’t think it’ll be a problem.

In reply to by Jojo-Schmitz

Yes, gratis, not Free.

I understand the move, I was just considering whether it’s a bad thing for this — see also https://mako.cc/copyrighteous/free-software-needs-free-tools — and came to the conclusion that it’s probably not (as it only affects people using a non-free operating environment in the first place).

The downside is that it now cannot be cross-compiled (create Win32 binaries on GNU/Linux) any more either, but AIUI MuseScore wasn’t using this anyway.

In reply to by mirabilos

Don't mix the definitions, MSVC is a C++ compiler. It has long history, it was a part of C++ Build tools, it was free as a separate tool and now it is part of all Visual Studio products (https://stackoverflow.com/questions/22290501/can-i-download-the-visual-…). MSVS, Microsoft Visual Studio is an IDE and Community is free version of this IDE.

Moreover, just FYI, msvc version doesn't even correlate with the visual studio version number. For example, msvc2014 corresponds to Visual Studio 2015 and msvc2015 to Visual Studio 2017.

In reply to by Jojo-Schmitz

Hi JoJo

So a leading question perhaps as it wasn't clear to my old brain in the announcement...

The announcement is saying this is "The common cross platform IDE"?

To me, picking one that does, is very logical.

Debate will always rage over different IDE's but having a common one will save a lot of challenges on cross platform management effort. I commend the decision.

I presume the answer is yes and that would explain things I've observed. I've noticed the last couple of MuseseScore 3 Nightly's for Mac were smaller in size, and the package was noticeably running faster ... This change made my interest peak a day or so ago when the new daily version was taking a little bit longer to verify the package along with the speed improvement - if yes mystery solved.

Sounds like a good thing for the project and thanks for all the efforts as it is appreciated...

In reply to by Ron Southworth

The announcement is saying this is "The common cross platform IDE"? - no. Announcement doesn't say it. Visual Studio works only under Windows. Btw, there is Visual Studio Code (IDE) which is truly cross-platform and work under Mac, Windows, Linux. Btw, MSVC (compiler) doesn't work on Linux and Mac since it is Windows only compatible compiler. Btw, Visual Studio Code can be used as an IDE on Linux with gcc and Mac with clang, respectively.

Mac were smaller in size, and the package was noticeably running faster - interesting notice. Thank you, we need to investigate, because we did nothing to reduce the size of the package or to optimize Mac build :)

In reply to by Anatoly-os

Thanks for the quick reply gents....

So why are the nightly builds loading quicker on my machine ....

Best thing I can come up with at the moment after spending quite a few hours on looking at it is that when I resolved a long term sound driver latency issue, an unexpected pleasant result has been that the machine running faster by about 20-30%. Yay.

Thanks Anatoly for the info. google and I are old friends so I found that out while you guys had your head on a pillow etc :)

I found some references on people trying to convert other apps to MAC, the challenges in converting the code dependancies and to work around it was by using Visual Studio Code. Seems the IDE for Windows might be on the road to working on Mac's if only for the latest version of OSX onwards.

btw ... my build size comment is based on comparisons to a build I had on file here from nearly 12 months ago that I was keeping as a "stable" version of the Musescore3 branch. It is about 100k larger so Jo Jo saying the more recent ones are around the same size, yep they are ....

In reply to by Anatoly-os

> Just curious, could Win binaries be created with mingw on GNU/Linux? Did anyone try to do it?

Yes, it is possible, but with some work. I managed to compile 32bit Windows MuseScore by using mxe ( https://mxe.cc/ ) packages under Linux Mint 18.3, but I had to skip genManual (it had to be run under wine), and compile also mxe with posix threads, and adjust the version of Qt (since mxe by default uses the latest one).
I think however there was not much difference with respect to MinGW compilation under Windows, except for the speed of compilation, faster than Windows in the same machine.
There also seems to be a QtWebKit module in the Qt5 compiled from mxe, but I don't how up-to-date it is.

I have no issues with switching compilers, but I'd really prefer not to have to install and learn a whole new IDE. Is it feasible (not just short-term) to continue to use QtCreator but use the Microsoft compilers?

In reply to by Anatoly-os

Still on the just-out-of-holidays crazy, but I know this is possible and have done it once in a dark and dusty part of my past…

My intention is indeed to add the MSVC toolchain to QtCreator as I'm more used to their layout than VisualStudio and believe their designer view has some nice advantages for projects that make use of a GUI. I'll make sure to once again screenshot and document my attempt/settings into the handbook.

I'm all in favour of anything that results in a quicker build time.
However, I've carefully followed the linked instructions, and I can't find mscore.sln anywhere.
I have pulled down the latest master branch from github... is there something I've missed? Is the visual studio stuff on a different branch? Is there a missing step?
Any help appreciated.

In reply to by Robbie Matthews

Hi. MSVC compilation infrastructure is in master. The mscore.sln is in the MSVC.build.debug folder. This folder is
generated automatically when you open MuseScore folder in Visual Studio (in case you installed cmake tools for Visual Studio).
Other quick way is to run msvc_build.bat debug from command line. It will generate all required folders and build MuseScore by itself. After that you can open msvc.build.debug folder, open mscore.sln, set mscore as startup project, run INSTALL project, set up the path to debugging .exe file and that's it. You can debug now :)

In reply to by Anatoly-os

I did, but did not realise that CMake was expecting it to be in a folder named "dependencies".
So that got me further, but I'm now getting this error.

CMake Error at mtest/CMakeLists.txt:31 (QT5_ADD_RESOURCES):
Unknown CMake command "QT5_ADD_RESOURCES". C:\Android\MuseScore\mtest/CMakeLists.txt 31

In reply to by Robbie Matthews

A couple of notes on the compile instructions:
* Dependencies.zip has to be unpacked into a "dependencies" folder (not immediately obvious)
* CMake "can't find resource" failures are probably because the qt\bin\5.9.X is not set properly in PATH. NOTE: It is NOT X, it is 5.9.3 or whatever. (I cut and pasted without engaging brain...)
*Opening the first folder creates mscv.build.debug etc. It takes a while. You need to make sure the background tasks are complete before continuing.
* When the instructions say go to mscore.sln", it means, use "Open Solution" to find mscore.sln, which will be in the newly created mscv.build.debug
* I would like a little more detail on how to set your debug options... I set the working folder to the mscv.install folder, but I'm not 100% sure it is the best approach.

I tried a command line compilation with MSVC and it is possible, but the newest MSVC version (Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26726 for x86) has problems with Qt 5.9.6 and older:
https://bugreports.qt.io/browse/QTBUG-67259
The compilation stops with error C3615.
In the thread, they say the bug will be solved with Qt5.9.7.
In the meantime, I manually edited Qt\5.9.6\msvc2015\include\QtCore\qalgorithms.h with the changes of
https://codereview.qt-project.org/#/c/224386/4/src/corelib/tools/qalgor…
and the compilation worked.
Note that I had to include Qt bin folder in the PATH and then run
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
to properly set all the variables needed for the compilation.

Do you still have an unanswered question? Please log in first to post your question.