C ++对MIDI功能的未定义引用 [英] C++ Undefined reference to MIDI function
问题描述
我只是想打印连接的MIDI输入的数量.我到底在做错什么?
I simply want to print the amount of connected MIDI inputs. What in the world am I doing wrong?
使用Code :: Blocks和GNU GCC编译器.
Using Code::Blocks and GNU GCC Compiler.
#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
int main() {
printf("%d", midiInGetNumDevs());
return 0;
}
编译后,我得到对
I get undefined reference to `midiInGetNumDevs@0' upon compiling.
推荐答案
您需要与winmm.lib
链接.在Visual Studio中,您可以通过将其添加到项目属性中的其他依赖项中来实现.
You need to link with with winmm.lib
. In Visual Studio, you do this by adding it to the Additional Dependencies in your project properties.
右键单击项目,选择 Properties ,然后选择 Linker ,然后选择 Input .将winmm.lib
添加到其他依赖项中的文件列表.
Right-click on the project, select Properties, then Linker, then Input. Add winmm.lib
to the list of files in Additional Dependencies.
编辑:刚注意到您正在使用GCC.在这种情况下,也许注释中链接的解决方案会更好.在标题后添加#pragma comment(lib, "winmm.lib")
.
just noticed you are using GCC. In this case, maybe the solution linked in the comments would be better. Add #pragma comment(lib, "winmm.lib")
after your headers.
这篇关于C ++对MIDI功能的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!