gpt4 book ai didi

c++ - 为什么这样的 OpenAL 代码会在 Visual Studio 2008 中出现这样的错误?

转载 作者:行者123 更新时间:2023-11-28 08:25:56 24 4
gpt4 key购买 nike

所以总的来说,我的代码非常简单——我正在尝试编写麦克风回声程序,这是它的开始(在我看来——我对 OpenAL 很谨慎)

#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include <stdio.h>

#include <al.h>
#include <alc.h>
#include <alut.h>


using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
cin.get();
return 0;
}
void BlockingCapture(ALCdevice *mCaptureDevice, ALCubyte *pBuffer,
ALCint iSamplesToGet)
{
ALCint capturedSamples = 0;
while(capturedSamples < iSamplesToGet)
{
ALCint avail;
alcGetIntegerv(mCaptureDevice, ALC_CAPTURE_SAMPLES, 1, &avail);
if(avail > 0/*or some threshold*/)
{
avail = min(avail, iSamplesToGet-capturedSamples);
alcCaptureSamples(mCaptureDevice, pBuffer, avail);
capturedSamples += avail;
pBuffer += avail;
}
else
Sleep(0);
}
}

当我尝试编译它时,它给了我 3 个错误

1) 错误 1 ​​error LNK2019: ссылка на неразрешенный внешний символ __imp__alcCaptureSamples в функции "void __cdecl BlockingCapture(struct ALCdevice_struct *,unsigned char *,int)"(?Block ingCapture@@YAXPAUALCdevice_struct@@PAEH@Z) HelloOpenALMic .obj HelloOpenALMic

2) 错误 2 error LNK2019: ссылка на неразрешенный внешний символ __imp__alcGetIntegerv в функции "void __cdecl BlockingCapture(struct ALCdevice_struct *,unsigned char *,int)"(?Block ingCapture@@YAXPAUALCdevice_struct@@PAEH@Z) HelloOpenALMic .obj HelloOpenALMic

3) 错误 3 fatal error LNK1120: 2 неразрешенных внешних элементов C:\Users\Avesta\Documents\Visual Studio 2008\Projects\OJ\OJ\V3\Debug\HelloOpenALMic.exe HelloOpenALMic

顺便说一句:(我已将此 post 作为我的代码的起点。)

如何摆脱它们?

最佳答案

您需要将 OpenAL 库链接到您的应用程序。

进入project properties->Linker->Input,添加openal32.lib到列表中。

关于c++ - 为什么这样的 OpenAL 代码会在 Visual Studio 2008 中出现这样的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4088455/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com