PlaySound function & Console App

This is a discussion on PlaySound function & Console App within the Windows Programming forums, part of the Platform Specific Boards category; Hi! I have a big problem with the PlaySound function in my console application. The problem is that when I ...

  1. #1
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Question PlaySound function & Console App

    Hi!

    I have a big problem with the PlaySound function in my console application. The problem is that when I build my project the linker fails. This is the message "Sound.obj : error LNK2019: unresolved external symbol __imp__PlaySoundA@12 referenced in function _main Debug/Sound.exe : fatal error LNK1120: 1 unresolved externals".

    And here is the code:
    Code:
    # include <stdio.h>
    # include <conio.h>
    # include <windows.h>
    
    int main ()
    {
        printf ("SOUND");
        PlaySound (TEXT ("Click.wav"), NULL, SND_FILENAME | SND_ASYNC);
        return 0;
    }
    I have VC++ .NET on WinXP PRO.

    Please help me .
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    You have to link the library "libwinmm.a" in your project. For the Dev compiler, it's Compiler->Options, then check-mark the "include the following in this project" box, and type :

    -lwinmm

    ...into the edit box. See if that works...

  3. #3
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    Alright, I've done a little search and I found that I have to add winmm.lib to my linker and now it is working.
    Last edited by GaPe; 06-26-2002 at 12:36 PM.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  4. Full Screen Console
    By St0rmTroop3er in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 09:59 PM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21