Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Build Error - Creating a DirectSound secondary buffer [modified]

Build Error - Creating a DirectSound secondary buffer [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestionannouncement
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Hasler
    wrote on last edited by
    #1

    The following code results in a Build Error **error LNK2001: unresolved external symbol _IID_IDirectSoundBuffer8** if I un-comment the 5th line: hr = pDirectSoundBuffer->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*) ppDirectSoundBufferInterface); I've added Dsound.lib to the Additional Dependencies for the Linker in this project. I've included Dsound.h which has the definition of IID_IDirectSoundBuffer8 in my .cpp file, so it should know all about the GUID Definition. :confused: Why has it pre-pended an underscore in the Build Error message (i.e. "**_**IID_IDirectSoundBuffer8")? I don't have one in my code. I used "IID_IDirectSoundBuffer8".

    // Create the buffer
    hr = lpDirectSound->CreateSoundBuffer(&dsbDescription, &pDirectSoundBuffer, NULL);
    if(SUCCEEDED(hr))
    {
    	//hr = pDirectSoundBuffer->QueryInterface(IID\_IDirectSoundBuffer8, (LPVOID\*) ppDirectSoundBufferInterface);
    	pDirectSoundBuffer->Release();
    }
    

    With the offending line commented out as above, the code builds ok and runs. Putting in a break-point and investigating the various values just prior to the offending line I have the following: hr = S_OK ......So it apparently created the Secondary Buffer Ok pDirectSoundBuffer.IUnknown.__vfptr[0] = 0x73f5d348 pDirectSoundBuffer.IUnknown.__vfptr[1] = 0x73f38f8c pDirectSoundBuffer.IUnknown.__vfptr[2] = 0x73f19105 dsbDescription.dwSize = 36 dsbDescription.Flags = 32960 (i.e. DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS) dsbDescription.dwBufferBytes = 5930 dsbDescription.dwReserved = 0 dsbDescription.lpwfxFormat.wFormatTag = 1 dsbDescription.lpwfxFormat.nChannels = 1 dsbDescription.lpwfxFormat.nSamplesPerSec = 11025 dsbDescription.lpwfxFormat.nAvgBytesPerSec = 11025 dsbDescription.lpwfxFormat.nBlockAlign = 1 dsbDescription.lpwfxFormat.wBitsPerSample = 8 dsbDescription.lpwfxFormat.cbSize = 0 dsbDescription.guid3DAlgorithm = {GUID_NULL} All values in dsbDescription correlate with what we should see for the selected Wave file. The QueryInterface method is supposed to retrieve a pointer to the interface for my object. i.e. it's supposed to fill the pointer ppDirectSoundBufferInterface with the correct pointer address for the DirectSound Buffer Interface of my new DirectSoundBuffer object. Any clues at to why this Build Error occurs would be most appreciated.

    Thank you in advance Paul.

    modified on Friday, Apri

    L 1 Reply Last reply
    0
    • P Paul Hasler

      The following code results in a Build Error **error LNK2001: unresolved external symbol _IID_IDirectSoundBuffer8** if I un-comment the 5th line: hr = pDirectSoundBuffer->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*) ppDirectSoundBufferInterface); I've added Dsound.lib to the Additional Dependencies for the Linker in this project. I've included Dsound.h which has the definition of IID_IDirectSoundBuffer8 in my .cpp file, so it should know all about the GUID Definition. :confused: Why has it pre-pended an underscore in the Build Error message (i.e. "**_**IID_IDirectSoundBuffer8")? I don't have one in my code. I used "IID_IDirectSoundBuffer8".

      // Create the buffer
      hr = lpDirectSound->CreateSoundBuffer(&dsbDescription, &pDirectSoundBuffer, NULL);
      if(SUCCEEDED(hr))
      {
      	//hr = pDirectSoundBuffer->QueryInterface(IID\_IDirectSoundBuffer8, (LPVOID\*) ppDirectSoundBufferInterface);
      	pDirectSoundBuffer->Release();
      }
      

      With the offending line commented out as above, the code builds ok and runs. Putting in a break-point and investigating the various values just prior to the offending line I have the following: hr = S_OK ......So it apparently created the Secondary Buffer Ok pDirectSoundBuffer.IUnknown.__vfptr[0] = 0x73f5d348 pDirectSoundBuffer.IUnknown.__vfptr[1] = 0x73f38f8c pDirectSoundBuffer.IUnknown.__vfptr[2] = 0x73f19105 dsbDescription.dwSize = 36 dsbDescription.Flags = 32960 (i.e. DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS) dsbDescription.dwBufferBytes = 5930 dsbDescription.dwReserved = 0 dsbDescription.lpwfxFormat.wFormatTag = 1 dsbDescription.lpwfxFormat.nChannels = 1 dsbDescription.lpwfxFormat.nSamplesPerSec = 11025 dsbDescription.lpwfxFormat.nAvgBytesPerSec = 11025 dsbDescription.lpwfxFormat.nBlockAlign = 1 dsbDescription.lpwfxFormat.wBitsPerSample = 8 dsbDescription.lpwfxFormat.cbSize = 0 dsbDescription.guid3DAlgorithm = {GUID_NULL} All values in dsbDescription correlate with what we should see for the selected Wave file. The QueryInterface method is supposed to retrieve a pointer to the interface for my object. i.e. it's supposed to fill the pointer ppDirectSoundBufferInterface with the correct pointer address for the DirectSound Buffer Interface of my new DirectSoundBuffer object. Any clues at to why this Build Error occurs would be most appreciated.

      Thank you in advance Paul.

      modified on Friday, Apri

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Take a look at the header file dsound.h and check that it is defining the correct version thus:

      #define DIRECTSOUND_VERSION 0x0800 /* Version 8.0 */

      d@nish[^] has the answer.

      P 1 Reply Last reply
      0
      • L Lost User

        Take a look at the header file dsound.h and check that it is defining the correct version thus:

        #define DIRECTSOUND_VERSION 0x0800 /* Version 8.0 */

        d@nish[^] has the answer.

        P Offline
        P Offline
        Paul Hasler
        wrote on last edited by
        #3

        Thanks for your response Richard. Below is the definiton in Dsound.h I'm running XP PRO SP3 on this old laptop so it will be defining DirectSound Version 9.0 My understanding was that this was still based on the DirectSound8 interfaces etc. Have I miss-understood? I'm only just starting to learn DirectSound, so that's highly likely. :sigh:

        #ifndef DIRECTSOUND_VERSION

        #if (NTDDI_VERSION < NTDDI_WINXP) /* Windows 2000 */
        #define DIRECTSOUND_VERSION 0x0700 /* Version 7.0 */
        #elif (NTDDI_VERSION < NTDDI_WINXPSP2 || NTDDI_VERSION == NTDDI_WS03) /* Windows XP and SP1, or Windows Server 2003 */
        #define DIRECTSOUND_VERSION 0x0800 /* Version 8.0 */
        #else /* Windows XP SP2 and higher, Windows Server 2003 SP1 and higher, Longhorn, or higher */
        #define DIRECTSOUND_VERSION 0x0900 /* Version 9.0 */
        #endif

        #endif // DIRECTSOUND_VERSION

        L 1 Reply Last reply
        0
        • P Paul Hasler

          Thanks for your response Richard. Below is the definiton in Dsound.h I'm running XP PRO SP3 on this old laptop so it will be defining DirectSound Version 9.0 My understanding was that this was still based on the DirectSound8 interfaces etc. Have I miss-understood? I'm only just starting to learn DirectSound, so that's highly likely. :sigh:

          #ifndef DIRECTSOUND_VERSION

          #if (NTDDI_VERSION < NTDDI_WINXP) /* Windows 2000 */
          #define DIRECTSOUND_VERSION 0x0700 /* Version 7.0 */
          #elif (NTDDI_VERSION < NTDDI_WINXPSP2 || NTDDI_VERSION == NTDDI_WS03) /* Windows XP and SP1, or Windows Server 2003 */
          #define DIRECTSOUND_VERSION 0x0800 /* Version 8.0 */
          #else /* Windows XP SP2 and higher, Windows Server 2003 SP1 and higher, Longhorn, or higher */
          #define DIRECTSOUND_VERSION 0x0900 /* Version 9.0 */
          #endif

          #endif // DIRECTSOUND_VERSION

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Well you need to see which one of these is actually enabled to check whether it's generating for 7, 8 or 9. If you open this in Visual Studio you should see two of them grayed out and one in normal definition which is the value being used by the compiler. I just checked on my system (Windows 7) and it uses 0x0800 which should build correctly.

          d@nish[^] has the answer.

          P 1 Reply Last reply
          0
          • L Lost User

            Well you need to see which one of these is actually enabled to check whether it's generating for 7, 8 or 9. If you open this in Visual Studio you should see two of them grayed out and one in normal definition which is the value being used by the compiler. I just checked on my system (Windows 7) and it uses 0x0800 which should build correctly.

            d@nish[^] has the answer.

            P Offline
            P Offline
            Paul Hasler
            wrote on last edited by
            #5

            Yes it's using DirectSound Version 9. The other's are grayed out. However it's still my understanding that there is no IID_IDirectSoundBuffer9 etc. It's all still based on DirectSound8. Is this not the case? The following line in Dsound.h is not grayed: DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e); I'm still also confused why the Build Error talks about _IID_IDirectSoundBuffer8 when neither I or my dog ever mentioned anything starting with an underscore.:confused: Currently trying to modify the nearest large vertical surface by craniofacial means. Thanks again for your responses. Your input is really appreciated.

            L 1 Reply Last reply
            0
            • P Paul Hasler

              Yes it's using DirectSound Version 9. The other's are grayed out. However it's still my understanding that there is no IID_IDirectSoundBuffer9 etc. It's all still based on DirectSound8. Is this not the case? The following line in Dsound.h is not grayed: DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e); I'm still also confused why the Build Error talks about _IID_IDirectSoundBuffer8 when neither I or my dog ever mentioned anything starting with an underscore.:confused: Currently trying to modify the nearest large vertical surface by craniofacial means. Thanks again for your responses. Your input is really appreciated.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              The leading underscore is put there by the compiler and the actual value should be found in the Dsound3d.lib file. If you do not have that (and its corresponding DLL) on your system then you need to get a copy of Directx8 libraries; some more info here[^].

              d@nish[^] has the answer.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups