IAudioClient::Initialize方法的未解析外部符号.API公司
Unresolved External Symbol for IAudioClient::Initialize method. WASAPI API
我正试图通过WASAPI工具建立并运行一个输入音频流记录样本。以下是我的意思链接:http://msdn.microsoft.com/en-us/library/windows/desktop/dd370800(v=vs.85).aspx
这是相关代码:
#include "InputTest.h"
#include "Audioclient.h"
#include "Mmdeviceapi.h"
void InputTest::TakeInput()
{
HRESULT hr;
//Parameter variables for stream initialization
AUDCLNT_SHAREMODE ShareMode = AUDCLNT_SHAREMODE_SHARED;
DWORD da = 0;
REFERENCE_TIME bufferDuration = 10;
REFERENCE_TIME periodicity = 5;
WAVEFORMATEX pFormat;
LPCGUID AudioSessionGuid = NULL;
GUID guid2 = *AudioSessionGuid;
HRESULT guidError = UuidCreate(&guid2); //could do some error checking here. //project -> properties -> Linker -> Command Line -> Rpctr4.lib
//guid2 now has a generated value
//give ASG the address of the newly generated guid2
AudioSessionGuid = &guid2;
//Instantiate WaveFormat
pFormat.wFormatTag = WAVE_FORMAT_PCM;
pFormat.cbSize = 10; //extra information sent over stream. Usually ignored in PCM format.
//If wFormatTag is WAVE_FORMAT_PCM, nAvgBytesPerSec must equal nSamplesPerSec × nBlockAlign
pFormat.nAvgBytesPerSec = 0;
pFormat.nSamplesPerSec = 0;
pFormat.nBlockAlign = 0;
pFormat.nChannels = 2;
pFormat.wBitsPerSample = 16; //PCM standard
//Pointer for stored audio stream
IAudioClient *iac = NULL;
//Endpoint device selection
IMMDeviceEnumerator *pEnumerator = NULL;
IMMDevice *pDevice = NULL;
HRESULT de;
de = pEnumerator -> GetDefaultAudioEndpoint(eRender, eConsole, &pDevice);
hr = iac -> IAudioClient::Initialize(ShareMode, da, bufferDuration, periodicity, &pFormat, AudioSessionGuid);
}`
完整错误消息:
error LNK2019: unresolved external symbol "public: virtual long __stdcall
IAudioClient::Initialize(enum _AUDCLNT_SHAREMODE,unsigned long,__int64,__int64,struct
tWAVEFORMATEX const *,struct _GUID const *)" (?
Initialize@IAudioClient@@UAGJW4_AUDCLNT_SHAREMODE@@K_J1PBUtWAVEFORMATEX@@PBU_GUID@@@Z)
referenced in function "public: void __thiscall InputTest::TakeInput(void)" (?
TakeInput@InputTest@@QAEXXZ)
任何建议都非常感谢,因为我现在正在阅读一本很好的C++实践书。这个错误是怎么回事?
错误:
hr = iac -> IAudioClient::Initialize(...
正确:
hr = iac->Initialize(...
您应该在这里调用COM接口指针的虚拟方法,而不是绕过vtable的特定函数(有关讨论,请参阅此问题)。
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 未解析的外部符号_MsiLocateComponentW@12.
- 在C++中使用 gRPC 时未解析的外部符号
- LibPrivoxy: 未解析的外部符号 __declspec(dllimport) int __stdcall Sta
- 尝试从 XamlApplication 编译 C++/WinRT 空白应用程序时,我收到未解析的外部符号 winrt_make_*
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 仅在少数方法(静态或共享库)中解析的外部符号
- 未解析的外部符号"__declspec(dllimport)与 Spdlog c++ 库
- 函数 _main (OPENGL C++) 中引用的未解析的外部符号 ________
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 使用静态 constexpr 成员的未解析外部符号
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- Dlib LNK2001未解析的外部符号USER_ERROR__consistent_build_configurati
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- 类模板上一个特定函数的未解析外部符号
- LNK2001:未解析的外部符号public:static类std::vector