lenmus / lomse

A C++ library for rendering, editing and playing back music scores.
MIT License
117 stars 28 forks source link

Build Problems on Windows #392

Closed Matthew-w56 closed 6 months ago

Matthew-w56 commented 6 months ago

Hello! I am very interested in your library since I am starting on a sheet music editing software called Arrange that I'll be working on with a team over the next year. But, I cannot for the life of me build your application.

Some background info: Windows 10 Home mingw32-make compiler cmake -G "MinGW Makefiles" ../ for building I have installed all the prerequisite libraries listed (though it still says it can't find unittest++)

I can get it to make the Makefiles for MinGW, but then when I try to build it gets exactly 7% in, and says that va_list isn't declared. Here is a copy of the terminal output when I try to do mingw32-make in the build folder: (Messy, sorry)


In file included from C:/Users/mbwil/Desktop/lomse/include/private/lomse_internal_model_p.h:37:0, from C:/Users/mbwil/Desktop/lomse/include/lomse_internal_model_defs.h:15, from C:/Users/mbwil/Desktop/lomse/include/lomse_internal_model.h:13, from C:/Users/mbwil/Desktop/lomse/include/lomse_command.h:14, from C:\Users\mbwil\Desktop\lomse\src\document\lomse_command.cpp:11: C:/Users/mbwil/Desktop/lomse/include/lomse_logger.h:157:64: error: 'va_list' has not been declared const string& prefix, const char fmtstr, va_list args); ^~~ C:/Users/mbwil/Desktop/lomse/include/lomse_logger.h:160:39: error: 'va_list' has not been declared string format(const char fmtstr, va_list args); ^~~ CMakeFiles\lomse.dir\build.make:225: recipe for target 'CMakeFiles/lomse.dir/src/document/lomse_command.cpp.obj' failed mingw32-make[2]: [CMakeFiles/lomse.dir/src/document/lomse_command.cpp.obj] Error 1 CMakeFiles\Makefile2:109: recipe for target 'CMakeFiles/lomse.dir/all' failed mingw32-make[1]: [CMakeFiles/lomse.dir/all] Error 2 Makefile:154: recipe for target 'all' failed mingw32-make: *** [all] Error 2

What could possibly be wrong here? I have a feeling that it is some problem with the compiler since it is failing to include a standard file that defines va_list, but I just don't know what could have caused this as I follow the instructions.

Any help would save me, I have sunk at least 10-15 hours into trying to make a test project build but to no avail so far. Thanks!

dmitrio95 commented 6 months ago

It seems it may be needed to move this line from lomse_logger.cpp to lomse_logger.h, then it should definitely have the necessary definition of va_list there. I don't know though why it works on other compilers now, probably there are some differences in the structure of their standard library's header files.

Matthew-w56 commented 6 months ago

I tried manually filling in the va_list with char* to see if that was the only problem and I'm getting other errors on other files for different things.

Would I be able to get recommendations for what someone else on Windows 10 is using? It may work just fine if I use the same compiler as someone who has it working

dmitrio95 commented 6 months ago

I don't use Lomse on Windows, but there is a CI build for Windows which uses the Visual Studio compiler, so that one should work. You can look at this file to see the detailed configuration of the build.

cecilios commented 6 months ago

I don't use Windows and building for Windows has always been a nightmare for me, specially with al the MT, MTD flags and the need that all linked libraries to be built with the same flags.

I usually build using the microsoft compiler and the ninja build tool.

open a Command Window appropiate for x64 build: "x64 Native Tools Command Prompt"

Create build directory:

cd path\to\lomse
rmdir build-area /S /Q
mkdir build-area && cd build-area

Create makefile and build:

cmake -G "Ninja" ..
ninja

You will see many warnings, mainly complaining about usafe function, such as:

'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

There are also a couple of other warnings that I have to fix.

The unit tests runner program testlib.exe is built and is linked against zlib.lib and libpng.lib but when executed, the testlib.exe program complains of not finding zlib.dll and libpng.dll (!!!???). Copying these DLLs to build folder solves the problem and the tests run. There are four test failures related to Chinese font.

To install the library and the header files it is required to have admin privileges. To do it, open as admin a "x64 Native Tools Command Prompt". Then:

cd path\to\lomse\build-area
ninja install