c++播放音频( c++ play audio),为C++应用程序添加启动音效

c++播放音频

0、使用的IDE : CLion

1、CMAKE中

cmake_minimum_required(VERSION 3.21)
project(Cpp)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_EXE_LINKER_FLAGS "-static")

add_executable(cheatMain main.cpp)

# Link to GLFW, GLEW and OpenGL
target_link_libraries(cheatMain PUBLIC
        ${GLFW_LIBRARIES}
        ${GLEW_LIBRARIES}
        ${OPENGL_LIBRARIES}
        winMM.Lib
        )

2、main.cpp中

int main {
PlaySound(TEXT("C:\\Users\\x'x'xxx\\Documents\\GitHub\\xx\\Cpp\\go.wav"),NULL, SND_ASYNC);
}

===================DEBUG的新路历程===============================

 clion

clion 添加link -Winmm.lib

clion undefined reference to `__imp_PlaySoundA'

播放出来的声音是  叮咚,不是我的音频

我的天 

Instead of using relative path Use an absolute path

posted @ 2022-03-22 16:07  bH1pJ  阅读(177)  评论(0编辑  收藏  举报