How do I install a c++ library so I can use it?

前端 未结 4 1966
情深已故
情深已故 2021-01-31 08:34

I have this library called BASS which is an audio library which I\'m going to use to record with the microphone. I have all the files needed to use it, but I don\'t know how to

4条回答
  •  情歌与酒
    2021-01-31 09:13

    See the code below code and don not forget to put bass.dll in the directory of your exe file and include the file bass.lib with your project and don not forget also to include the path to bass.h and bass.lib in the default include and lib path of your project.

    #include 
    #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;
    }
    

提交回复
热议问题