【问题标题】:Playing sound using MinGW使用 MinGW 播放声音
【发布时间】:2018-04-07 17:49:55
【问题描述】:

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

#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 编译这个示例?

【问题讨论】:

  • 这篇文章描述了如何链接dll而不是如何编译,我可以在哪里找到头文件和lib等。
  • 您不需要 lib 文件来编译。标头只是windows.h(包括winmm.h

标签: c++ audio mingw


【解决方案1】:

一旦我删除了 MSVS-isms

#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

as per the linked duplicate,构建成功。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-12
    • 2014-08-15
    • 2014-04-01
    • 2021-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多