包括MMSystem.h 我写了一个简单的C++程序,需要使用MyStase.H.
我用g++-g编译它。\audiodemo.cpp-o audio-lm-lwinmm,但它抛出了一个错误 MMSystem.h:没有这样的文件或目录 我甚至还没有开始在我的代码中使用彩信系统,还以为它是一个标准库包括MMSystem.h 我写了一个简单的C++程序,需要使用MyStase.H.,c++,audio,compilation,linker,C++,Audio,Compilation,Linker,我用g++-g编译它。\audiodemo.cpp-o audio-lm-lwinmm,但它抛出了一个错误 MMSystem.h:没有这样的文件或目录 我甚至还没有开始在我的代码中使用彩信系统,还以为它是一个标准库 #include <iostream> #include <Windows.h> #include <MMSystem.h> using namespace std; const int NUMPTS = 44100 * 10; // 10
#include <iostream>
#include <Windows.h>
#include <MMSystem.h>
using namespace std;
const int NUMPTS = 44100 * 10; // 10 seconds
int sampleRate = 44100;
short int waveIn[NUMPTS]; // 'short int' is a 16-bit type; I request 16-bit samples below
int main(){
PlaySound(TEXT("CantinaBand3.wav"), NULL, SND_FILENAME | SND_ASYNC);// - the correct code
int test = 0;
cin>>test;
return 0;
}
如果您使用的是代码块IDE,请首先转到设置,然后单击编译器,然后转到链接器设置并将winmm添加到库部分。它不会显示任何错误。 MMSORCTION.H是Windows .h的同一个Windows SDK的一部分,它不是C++本身的标准标头。您是否为编译器安装了Windows SDK?您是否已正确配置编译器的搜索路径以查找该SDK的文件?另外,您不需要手动使用include,因为windows.h默认情况下已经为您这样做了。@Remy Lebeau-Hmm有趣。我还没有安装windowsSDK,但是如果windows.h是windowsSDK的一部分,为什么不会给我带来一个错误呢?而且,标题名都是小写的:有些系统甚至编译器对文件名都是区分大小写的。我在Windows10上编译这个