使用MinGW播放声音

Playing sound using MinGW

本文关键字:播放声音 MinGW 使用      更新时间:2023-10-16

我想使用 mciSendString 在我的应用程序中播放声音。为此,我在Microsoft网站上找到了以下简单片段:

#include "stdafx.h"
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib, "Winmm.lib")
int _tmain(int argc, _TCHAR* argv[])
{
  mciSendString("play MyFile wait", NULL, 0, 0);
  mciSendString("close MyFile", NULL, 0, 0);
  return 0;
}

我的问题是我不使用Visual Studio。有没有办法通过MinGW编译此示例?

一旦我删除了MSVS主义

#include <windows.h>
int main()
{
  mciSendString("play MyFile wait", NULL, 0, 0);
  mciSendString("close MyFile", NULL, 0, 0);
  return 0;
}

并编译使用

g++ -o test.exe "src\test.o" -lwinmm

根据链接的副本,生成成功。