c++ - 包括MMSystem.h
问题描述
我正在编写一个简单的 C++ 程序,我需要在其中使用MMSystem.h
.
我用 编译它g++ -g .\audiodemo.cpp -o audio -lm -lwinmm
,但它会引发错误
MMSystem.h:没有这样的文件或目录
我什至还没有开始mmsystem
在我的代码中使用它并认为它是一个标准库。
#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添加到库部分。然后它不会显示任何错误。
推荐阅读
- c - 用gcc修改补丁认证程序
- c# - 如何使用 Winium Desktop c# 复制、粘贴、删除文件或文档
- laravel - 个人访问令牌 - Laravel
- python - TensorFlow 中 session.run() 执行时间增加
- r - 在一个 ggplot 图中使用不同长度的刻度
- javascript - 如何避免在javascript中等待地狱
- powershell - Powershell Core中的“对象引用未设置为对象的实例”
- rust - 遍历对 Chars 的引用
- python - 如何将行读入多个文件
- postgresql - 如何将 CASE WHEN 语句限制为仅显示 ELSE 值?