PlaySound

my code for PlaySound is like this:

1
2
3
4
5
6
7
#include <windows.h>
#include <mmsystem.h> 
int main() 
{
PlaySound(L"release\\test16bit.wav", NULL, SND_SYNC); 
return 0; 
}

when I build it, I always got error like this:

 
error LNK2019: unresolved external symbol WinMain referenced in function WinMainCRTStartupHelper


Please help, I cannot figure out why I alway got this kind of error, How to fix it?
Thank you very much!
Did you link with winmm?
i change a little about the above code to add

 
#pragma comment(lib, "winmm")  


but still got the same link error

1
2
3
4
5
6
7
8
#include <windows.h> 
#include <mmsystem.h> 
#pragma comment(lib, "winmm") 
int main() 
{
PlaySound(L"release\\test16bit.wav", NULL, SND_SYNC); 
return 0; 
}
This pronlem usually turns up when you select Win32 Application which is a GUI application as the project type, and then write code for a Console Application (using int main () ).

Throw this project away, and start a new one, AND MAKE SURE that you select Win32 Console Application as the project type

and put the above code in the new project and see what happens.
Last edited on
Topic archived. No new replies allowed.