当前位置 : 主页 > 编程语言 > c++ >

vs2015 编译obs studio 遇到的几个错误

来源:互联网 收集:自由互联 发布时间:2021-06-23
1. D:\project\vs\obs\ObsProject\obs-studio\plugins\win-wasapi\win-wasapi.cpp(245): error C2065: “KSAUDIO_SPEAKER_2POINT1”: 未声明的标识符 1D:\project\vs\obs\ObsProject\obs-studio\plugins\win-wasapi\win-wasapi.cpp(245): error C213

1. 

>D:\project\vs\obs\ObsProject\obs-studio\plugins\win-wasapi\win-wasapi.cpp(245): error C2065: “KSAUDIO_SPEAKER_2POINT1”: 未声明的标识符
1>D:\project\vs\obs\ObsProject\obs-studio\plugins\win-wasapi\win-wasapi.cpp(245): error C2131: 表达式的计算结果不是常数
1> D:\project\vs\obs\ObsProject\obs-studio\plugins\win-wasapi\win-wasapi.cpp(245): note: 非常量参数或对非常量符号的引用导致了故障
1> D:\project\vs\obs\ObsProject\obs-studio\plugins\win-wasapi\win-wasapi.cpp(245): note: 请参见“KSAUDIO_SPEAKER_2POINT1”的用法

解决方案:

再win-wasapi.cpp 内添加定义KSAUDIO_SPEAKER_2POINT1 宏:

#define KSAUDIO_SPEAKER_2POINT1     (KSAUDIO_SPEAKER_STEREO|SPEAKER_LOW_FREQUENCY)

2.

D:\project\vs\obs\ObsProject\obs-studio\plugins\win-wasapi\win-wasapi.cpp(245): error C2051: case 表达式不是常量
2>d:\project\vs\obs\obsproject\obs-studio\deps\json11\json11.hpp(110): error C2228: “.begin”的左边必须有类/结构/联合 (编译源文件 D:\project\vs\obs\ObsProject\obs-studio\deps\json11\json11.cpp)
2> d:\project\vs\obs\obsproject\obs-studio\deps\json11\json11.hpp(110): note: 类型是“add_rvalue_reference<_Ty>::type” (编译源文件 D:\project\vs\obs\ObsProject\obs-studio\deps\json11\json11.cpp)
2>d:\project\vs\obs\obsproject\obs-studio\deps\json11\json11.hpp(110): error C2227: “->first”的左边必须指向类/结构/联合/泛型类型 (编译源文件 D:\project\vs\obs\ObsProject\obs-studio\deps\json11\json11.cpp)
2>d:\project\vs\obs\obsproject\obs-studio\deps\json11\json11.hpp(111): error C2228: “.begin”的左边必须有类/结构/联合 (编译源文件 D:\project\vs\obs\ObsProject\obs-studio\deps\json11\json11.cpp)
2> d:\project\vs\obs\obsproject\obs-studio\deps\json11\json11.hpp(111): note: 类型是“add_rvalue_reference<_Ty>::type” (编译源文件 D:\project\vs\obs\ObsProject\obs-studio\deps\json11\json11.cpp)
2>d:\project\vs\obs\obsproject\obs-studio\deps\json11\json11.hpp(111): error C2227: “->second”的左边必须指向类/结构/联合/泛型类型 (编译源文件 D:\project\vs\obs\ObsProject\obs-studio\deps\json11\json11.cpp)

解决方案:

参考之前版本的json11 然后提换一下现在的json11文件。

具体差异:

再 json11.hpp 添加:

// declval example
#include <utility> // std::declval
#include <iostream> // std::cout
template<class T>
typename std::add_rvalue_reference<T>::type declval() noexcept;

using namespace std;

然后下面提换内容:

//此处最新版的代码编译会有问题所以注释起来还是使用之前版本的代码进行编译 by_songgp add20190422
/*
    // Implicit constructor: anything with a to_json() function.
    template <class T, class = decltype(&T::to_json)>
    Json(const T & t) : Json(t.to_json()) {}

    // Implicit constructor: map-like objects (std::map, std::unordered_map, etc)
    template <class M, typename std::enable_if<std::is_constructible<std::string, decltype((std::declval<M>()).begin()->first)>::value&& std::is_constructible<Json, decltype(std::declval<M>().begin()->second)>::value, int>::type = 0>
    Json(const M & m) : Json(object(m.begin(), m.end())) {}

    // Implicit constructor: vector-like objects (std::list, std::vector, std::set, etc)
    template <class V, typename std::enable_if<std::is_constructible<Json, decltype(*std::declval<V>().begin())>::value, int>::type = 0>Json(const V & v) : Json(array(v.begin(), v.end())) {}

    // This prevents Json(some_pointer) from accidentally producing a bool. Use
    // Json(bool(some_pointer)) if that behavior is desired.
    Json(void *) = delete;

    // Accessors
    Type type() const;
*/

    // Implicit constructor: anything with a to_json() function.
    template <class T, class = decltype(&T::to_json)>
    Json(const T & t) : Json(t.to_json()) {}

    // Implicit constructor: map-like objects (std::map, std::unordered_map, etc)
    template <class M, typename std::enable_if<
        std::is_constructible<std::string, typename M::key_type>::value
        && std::is_constructible<Json, typename M::mapped_type>::value,
        int>::type = 0>
        Json(const M & m) : Json(object(m.begin(), m.end())) {}

    // Implicit constructor: vector-like objects (std::list, std::vector, std::set, etc)
    template <class V, typename std::enable_if<
        std::is_constructible<Json, typename V::value_type>::value,
        int>::type = 0>
        Json(const V & v) : Json(array(v.begin(), v.end())) {}

    // This prevents Json(some_pointer) from accidentally producing a bool. Use
    // Json(bool(some_pointer)) if that behavior is desired.
    Json(void *) = delete;

    // Accessors
    Type type() const;

3.

-preview.cpp(932): error C2719: ‘transform‘: formal parameter with requested alignment of 16 won‘t be aligned

原因可能是因为vs2015 编译的是win3 

解决方案:

修改  window-basic-preview.cpp 文件中

static bool IntersectBox(matrix4 transform, float x1, float x2, float y1,
             float y2)

为下面的内容:

static bool IntersectBox(matrix4& transform, float x1, float x2, float y1,
             float y2)

参考:

https://blog.csdn.net/kupepoem/article/details/44239193

网友评论