WebRTC Precompiled 使用

最近研究webrtc native code,但源码太大(10GB以上)又需要FQ,就找了个预编译的版本https://sourcey.com/precompiled-webrtc-libraries

下面把引入库的经验写下来

首先需添加宏定义 #define WEBRTC_WIN 不然会报以下错误

Must define either WEBRTC_WIN or WEBRTC_POSIX.

接着还需定义 #define NOMINMAX 因为windows.h中的min max函数与std标准库的冲突

 这时只剩下两个错误 

 C4996 '_vsnwprintf': This function or variable may be unsafe. Consider using _vsnwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

加入#define _CRT_SECURE_NO_WARNINGS 

 

还有一个错误,不过编译已经通过了

E1574 静态断言失败,原因是 ".data() and .size() are private"

 

 LNK2038 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“0”不匹配值“2”

 加入预处理#define _ITERATOR_DEBUG_LEVEL 0 

 可能是Debug项目用到了Release的库 

 

 LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”

项目属性-C/C++-代码生成-运行库 改为多线程(/MT)

 

示例如下,输出视频设备数量

#define WEBRTC_WIN
#define NOMINMAX
#define _ITERATOR_DEBUG_LEVEL 0

#pragma comment(lib, "libwebrtc_full.lib")
#pragma comment( lib, "strmiids.lib" )
#pragma comment(lib, "winmm.lib ")

#include "webrtc/modules/video_capture/video_capture_factory.h"


#include <iostream>


int main()
{
    std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(webrtc::VideoCaptureFactory::CreateDeviceInfo());

    if (info) {
        int num_devices = info->NumberOfDevices();
        std::cout << (num_devices);
    }
    
    std::cout << "Hello World!\n"; 
}

 

posted @ 2019-04-28 10:55  kakain  阅读(1193)  评论(0编辑  收藏  举报