Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Source Safe / December 2003

Tip: Looking for answers? Try searching our database.

Visual C++.Net 2003: cannot make PlaySound(,,) function to link.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 17 Dec 2003 08:17 GMT
Using the W2K+SP4 platform.

When trying to build an .EXE, targetting a CONSOLE application that has
either one of the following two lines:

1.  PlaySound("SystemExclamation",NULL,SND_ALIAS);
2.  PlaySound("H:\\My_Music\\abc.mpg",NULL,SND_FILENAME | SND_ASYNC);

Compiler is happy but linker complains:
Test.obj : error LNK2019: unresolved external symbol __imp__PlaySoundA@12
referenced in function _main
Release/Test.exe : fatal error LNK1120: 1 unresolved externals

I do have the following inclusions:

   #include <iostream>
   #include <cstring>
   #include <string.h>
   #include <stdio.h>
   #include <stdlib.h>
   #include <windows.h>
   #include <winver.h>
   using namespace std;

What am I missing ? Any additional header or .DLL/.OBJ (static) linking
required?
Or is it possible that I can not target a Console application using the
PlaySound() function?
What are the alternative functions if PlaySound() is inappropriate?

Many thanks,

David
Alin Constantin [MSFT] - 22 Dec 2003 19:41 GMT
Hi David,

As per
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_w
in32_playsound.asp

the PlaySound function is implemented in Winmm.lib
     Header: Declared in Mmsystem.h; include Windows.h.
     Library: Use Winmm.lib.
So, you need to link to that library in order to use the function.
If you're using VisualStudio 2002/2003, use the Project's property pages and
add 'winmm.lib' in the Linker/Input/AdditionalDependencies list.
Signature

Alin Constantin
[This posting is provided "AS IS" with no warranties, and confers no
rights.]

> Using the W2K+SP4 platform.
>
[quoted text clipped - 29 lines]
>
> David

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.