Solved

getting winmm.lib with PlaySound into the project settings

Posted on 1998-10-28
3
524 Views
Last Modified: 2013-11-20
I'm trying to play a wav file with PlaySound and include <mmsystem.h>.  The build fails at the link with the following message:

error LNK2001: unresolved external symbol __imp__PlaySoundA@12

I tried to add winmm.lib to the project settings, but must be doing it incorrectly.  What changes do I need to make to the project settings?
0
Comment
Question by:Ashurbanipal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
stefanr earned 50 total points
ID: 1323956
The easiest way of including a lib file is to tell it directly in the source code (for Visual C++), as below:

#include <mmsystem.h>

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

We have done this a number of times (including this particular files), and it has never failed.

Hope this helps.
0
 

Author Comment

by:Ashurbanipal
ID: 1323957
I already had the following line at the top of the .cpp file:

#include <mmsystem.h>

Without that the file generates errors because it doesn't recognize PlaySound.  The error occurs while linking, that is why it must have something to do with the project settings.
0
 
LVL 3

Expert Comment

by:stefanr
ID: 1323958
the

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

is used at link time to link to the .lib file in question. Therefore you shouldn't get any linking errors if you add this line in your cpp file (unless somehow the LIB-path is not set properly; see your environment in a console window using the SET command). You could also add the winmm.lib in the Project Settings/Link/Object+Library modules, but in that case you have to do it every time you use the same source files in new projects. It's easier to use #pragma comment(lib, "...").

If your LIB path in the console window lacks the paths similar to
c:\program\devstudio\vc\lib;c:\program\devstudio\vc\mfc\lib
you have to add them using (in NT) the Control Panel/System/Environment. I'm not sure about Windows 95/98, but maybe you have to edit the autoexec.bat file to add this environment variable.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question