Thread: How to play sound in C++?

  1. #1
    Registered User
    Join Date
    Sep 2018

    How to play sound in C++?

    Oh god I have been looking everywhere but I can't get a sound to play on C++.

    I included windows.h and mmsystem.h and tried the following:
    PlaySound(TEXT("1.wav"), NULL, SND_SYNC);

    I get the error
    Error LNK2019 unresolved external symbol __imp_PlaySoundA referenced in function main QuizWiz
    every single time.

    What am I doing wrong? And while we're at it any tutorials to work with sounds in C++? Or libraries if C++ doesn't support it?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    PlaySound function (Windows)
    Scroll right to the end, where it tells you about winmm.lib

    You need to tell the compiler, actually the linker, where to get the code that implements the function.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. play sound in C?
    By nutzu2010 in forum C Programming
    Replies: 12
    Last Post: 01-01-2011, 02:38 PM
  2. Play sound on a Mac
    By Joealem in forum Linux Programming
    Replies: 4
    Last Post: 12-27-2010, 05:41 PM
  3. How to play a sound
    By asofaihp in forum C++ Programming
    Replies: 16
    Last Post: 09-02-2009, 09:37 PM
  4. Play Sound in a game..
    By BODYBUILDNERD in forum Game Programming
    Replies: 6
    Last Post: 12-12-2002, 11:37 AM
  5. How to play a sound in MFC?
    By algorithm in forum Windows Programming
    Replies: 3
    Last Post: 11-16-2001, 08:05 PM

Tags for this Thread