无法编译 RtMidi VS community 2015

Cannot compile RtMidi VS community 2015

我正在学习 https://www.music.mcgill.ca/~gary/rtmidi/ 上的基础教程,但我似乎无法通过 "Getting Started."

中的第一步

最初我只收到两个错误,其中一个是 "LNK2019 - unresolved external symbol" 错误,我通过链接 rtmidi.lib 和 rtmidid.lib

修复了这个错误

现在我有一大堆无法理解的错误

rtmidi.lib(RtMidi.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
RTMIDI_test.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
rtmidi.lib(RtMidi.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in RTMIDI_test.obj
rtmidi.lib(RtMidi.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in RTMIDI_test.obj
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInUnprepareHeader@12
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInOpen@20
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiOutGetDevCapsW@12
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiOutPrepareHeader@12
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiOutOpen@20
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInReset@4
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInPrepareHeader@12
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiOutUnprepareHeader@12
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInGetDevCapsW@12
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInStart@4
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInClose@4
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInAddBuffer@12
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInGetNumDevs@0
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiOutShortMsg@8
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiOutGetNumDevs@0
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiOutLongMsg@12
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiOutClose@4
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInStop@4
rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiOutReset@4
C:\Users\Zach\Desktop\RTMIDI_test\Debug\RTMIDI_test.exe : fatal error     LNK1120: 19 unresolved externals

显然在第 7-25 行,它正在寻找一个库或不存在的东西,但没有给出关于它是什么的提示。然而,其余的,我什至无法开始弄清楚。有什么想法吗?

我在其他地方读到将项目选项更改为 "Release" 这确实删除了上述消息,而是将它们替换为

RTMIDI_test.obj : error LNK2001: unresolved external symbol "public: __thiscall RtMidiIn::RtMidiIn(enum RtMidi::Api,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int)" (??0RtMidiIn@@QAE@W4Api@RtMidi@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I@Z)
C:\Users\Zach\Desktop\RTMIDI_test\Release\RTMIDI_test.exe : fatal error LNK1120: 1 unresolved externals

大多数 link 错误会告诉您需要做些什么来修复它们(至少结合一些谷歌搜索)

rtmidi.lib(RtMidi.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in RTMIDI_test.obj
rtmidi.lib(RtMidi.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in RTMIDI_test.obj

所以 RTMIDI_test.cpp 编译时 _ITERATOR_DEBUG_LEVEL 的值与 rtmidi.lib 不同。下一行表示您正在尝试 link 您的调试项目使用 rtmidi.lib 的发布版本。您应该针对调试版本将其更改为 link 而不是应该删除一些或所有其他警告和错误。

rtmidi.lib(RtMidi.obj) : error LNK2001: unresolved external symbol __imp__midiInUnprepareHeader@12

midiInUnprepareHeader 和其他 midiIn* 函数存在于 winmm.lib 中(参见 docs),因此您还需要 link 反对它。