Search code examples
c++visual-studiovisual-c++midi

How to compile RtMidi API properly on Windows


I’m using C++ on visual studio 2019 and having issues trying to link my project to PortAudio. When I use the RtAudio header file in a project, I get the error message "MidiInDummy: This class provides no functionality." Most solutions I can find online say to add __WINDOWS_MM__ to the pre-processor definitions and link to winmm.lib (as instructed on https://www.music.mcgill.ca/~gary/rtmidi/) However, having done this, I am still getting the same problem.


Solution

  • I get the error message "MidiInDummy: This class provides no functionality."

    This warns that no valid MIDI API was defined. The warning is issued from the constructor of the MidiInDummy class in rtMidi.cpp, which is just a placeholder without functional implementation.

    add __WIN_MM__ to the pre-processor definitions

    That is the wrong #define for the Windows build, which explains the MidiInDummy warning. The correct definition, listed on the reference page under Compiling is:

    #define __WINDOWS_MM__
    

    Once __WINDOWS_MM__ is defined, the sample cMidiIn.dsp project builds fine with VS 2019 after fixing a few remaining minor issues:

    • error D8016: '/ZI' and '/Gy-' command-line options are incompatible - change project Properties / C/C++ / General / Debug Information from /ZI to /Zi;

    • warning D9035: option 'Gm' has been deprecated and will be removed in a future release - change project Properties / C/C++ / Code Generation / Enable Minimal Rebuild from /Gm to /Gm-;

    • warning C4138: '*/' found outside of comment - add a space before /*userData*/ in:

      void mycallback(double deltatime, std::vector< unsigned char >* message, void* /*userData*/)