Build Error - Creating a DirectSound secondary buffer [modified]
-
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
-
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
-
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
-
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
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.
-
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.
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. -
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.