Computing.Net > Forums > Programming > C++ PlaySound() error

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C++ PlaySound() error

Reply to Message Icon

Name: djas
Date: November 1, 2005 at 13:20:59 Pacific
OS: Windows XP Pro SP2
CPU/Ram: P4 2.40 GHZ 256 RAM
Comment:

Hey guys,
Im using the PlaySound() function for the first time and am getting this error:

"undefned reference to 'PlaySoundA@12'"

I read somewhere that I needed to link a file or something but have no idea how!

All help appreciated.
Thanx

djas



Sponsored Link
Ads by Google

Response Number 1
Name: tommycoolman
Date: November 2, 2005 at 00:22:19 Pacific
Reply:

PlaySound requires the Winmm.lib library.

#pragma comment(lib,"Winmm.lib")

I assume you're using Visual C++?
I have an example of a command line
program that uses PlaySound().

http://www.tommycoolman.com/misc/playsound.zip



0

Response Number 2
Name: djas
Date: November 2, 2005 at 08:59:43 Pacific
Reply:

Well actually I'm using MinGW but will this still work?

djas


0

Response Number 3
Name: djas
Date: November 4, 2005 at 08:04:12 Pacific
Reply:

Im still getting this error can anyone help,
heres the code, its only basic because I have never used PlaySound before now so.

:CODE:

#include <iostream>
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib,"Winmm.lib")
using namespace std;

int main()
{
PlaySound("Music", 0, SND_RESOURCE | SND_NODEFAULT);
return 0;
}

:/CODE:

All help appreciated
Thanx

djas


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C++ PlaySound() error

C++ compiling error www.computing.net/answers/programming/c-compiling-error/20145.html

Ms Visual C++ Externals Error www.computing.net/answers/programming/ms-visual-c-externals-error/5349.html

Body already defined error in C++ www.computing.net/answers/programming/body-already-defined-error-in-c/3612.html