title: PlaySound in C++ Console application?
body: <p>EDITED SO THE CODE IS CORRECT (THANKS TO ta.speot.is) - NEW QUESTION AT BOTTOM</p>
  <p>So I have been playing with the console as I am at that level, and we have been asked to make our first &quot;project&quot; for a assessment. I have the basic application all done.. but i wanted to jaz it up a bit and add some sounds. Sounds that will play from the console.</p>
  <p>This test works(kind of), as it will play a sound file, but there are 2 problems...</p>
  <ol>
  <li><p>When the sound starts playing, the application freezes until it finishes playing.</p>
  </li>
  <li><p>When I try to compile as a &quot;release&quot; it errors with a &quot;linking error&quot; - fatal error LNK1120: 1 unresolved externals.</p>
  </li>
  </ol>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;mmsystem.h&gt;
  using namespace std;
  
  int main(){
      //PlaySound(TEXT(&quot;mywavsound.wav&quot;), NULL, SND_FILENAME); - My erroring code
      PlaySound(TEXT(&quot;mywavsound.wav&quot;), NULL, SND_FILENAME | SND_ASYNC);// - the correct code
          
      int test = 0;
      cin&gt;&gt;test;
      return 0;
  }
  </code></pre>
  <p>So my questions are...</p>
  <ol>
  <li><p><em>How can I play sounds without freezing the console, so I can for
  example play looping music file while the project
  is running? Also it would be great if I could play other sounds on top
  of it, for example when you press enter it will plays a sound
  without stopping the music.</em></p>
  </li>
  <li><p><em>How do I add the wav file so it compiles as a release?</em></p>
  </li>
  </ol>
  <p><strong>EDIT</strong></p>
  <p>I know about the <code>SND_ASYNC</code> thing but I do not know how to use it, I can't seem to use it without the thing not compiling.. does anyone have an example of a code using <code>SND_ASYNC</code>?</p>
  <p><strong>EDIT 2</strong></p>
  <p>So I have this working now.... using the</p>
  <pre class="lang-cpp prettyprint-override"><code>PlaySound(TEXT(&quot;mysound.wav&quot;), NULL, SND_FILENAME | SND_ASYNC);
  </code></pre>
  <p>Now I am wondering how I can get 1 or more sounds to play at once, for if I call <code>PlaySound()</code> twice with that flag it will stop the 1st one and play the 2nd.. <em>Is there a way to play 2 sounds at once?</em></p>