rze*_*erg 23 c++ windows installation mingw
我有一个名为BASS的库,这是一个音频库,我将用它来录制麦克风.我有使用它所需的所有文件,但我不知道如何安装库.我尝试将示例文件放在与bass.h文件相同的目录中.但是我得到了一堆错误,说有不存在的函数调用.
所以我的问题是,如何安装它才能使用它?
Fra*_*sco 18
安装C++库意味着向感兴趣的软件(例如编译器)指定两种文件的位置:标头(典型扩展名*.h或.hpp)和编译对象(例如 .dll或*.lib).
标题将包含库作者向开发人员公开的声明,并且您的程序将在其源代码中包含它们,dll将包含已编译或链接在一起并由程序使用的编译代码,它们将是由链接器找到(或动态加载,但这是另一步).
所以你需要
1) put the header files in a location which your compiler is aware of (typically IDE allows to set so-called include directories, otherwise you specify a flag like "-I<path-to-headers>" when invoking the compiler)
2) put the dll files in a location which your linker is aware of (surely your IDE will allow that, otherwise you speficy a flag like "-L<path-to-libraries> -l<name-of-libraries>"
Run Code Online (Sandbox Code Playgroud)
最后但同样重要的是,既然我看到BASS库是商业产品,他们可能会提供一些安装说明吗?
小智 7
在终端或控制台中运行此命令。
cpp -v
Run Code Online (Sandbox Code Playgroud)
请注意,在输出的末尾,您将看到如下一行:
#include<...> search starts here:
Run Code Online (Sandbox Code Playgroud)
该行下方将有一个目录列表。将包文件夹移动到这些目录之一。然后尝试使用 <> 导入模块。
小智 6
请参阅下面的代码,不要忘记将 bass.dll 放在 exe 文件的目录中,并将文件 bass.lib 包含在您的项目中,并且不要忘记将 bass.h 和 bass.lib 的路径包含在项目的默认包含和库路径。
#include <iostream>
#include "bass.h"
using namespace std;
int main(int argc, const char **argv)
{
if (!BASS_Init(-1, 44100, 0, NULL ,NULL))
{
cout<<"Can't initialize device";
return -1;
}
int stream = BASS_StreamCreateFile(false, "D:\\mypro\\Trans_Langs\\germ\\quran_amma\\Translations\\Sound_aya\\Sora1\\Hafs\\basfar\\a7.mp3", 0L, 0L, 0);
if (stream != 0)
{
// play the stream channel
BASS_ChannelPlay(stream, false);
}
else
{
// error creating the stream
cout<<"Stream error: {0}", BASS_ErrorGetCode();
}
getchar();
BASS_StreamFree(stream);
// free BASS
BASS_Free();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
51699 次 |
最近记录: |