Thread: PlaySound function & Console App

  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,708
    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...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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, 02: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