gpt4 book ai didi

C++ PlaySound() 错误

转载 作者:行者123 更新时间:2023-11-28 02:07:08 25 4
gpt4 key购买 nike

我想就有关音乐操作的应用程序提出一个问题:我用函数 PlaySound() 编译了一个程序,但显示了以下消息:[Linker error] undefined reference到“PlaySoundA@12”。我使用 Dev c++ 来做到这一点,因为我的 visual studio 有问题,我无法登录我的 Microsoft 帐户,也不允许我使用它。好吧,我不知道出了什么问题,也不让我播放声音。我包含了 windows.h 和 mmsystem.h header ,并且都已正确编写。谁能帮我解决这个问题?

#include <windows.h>
#include <mmsystem.h>

int main(){
PlaySound("test.wav", NULL, SND_FILENAME);
return 0;
}

最佳答案

您需要将编译器链接到 winmm.lib 库才能正确链接。

关于C++ PlaySound() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37055108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com