美文网首页
安装并使用absl/abseil

安装并使用absl/abseil

作者: panjinya | 来源:发表于2020-04-30 15:22 被阅读0次

    absl简介

    问题来源

    在xcode中尝试编译webrtc源码时,提示absl/types/optional.h file not found
    可是在third_party里面明明有absl啊,什么鬼。。。

    解决步骤

    1.下载abseil源码,执行命令如下:

    git clone https://github.com/abseil/abseil-cpp.git
    

    2.使用cmake安装,执行命令如下:

    cmake -L CMakeLists.txt && make
    

    出现错误如下:

    /Users/username/Workspace/abseil-cpp/absl/base/policy_checks.h:77:2: error: "C++ versions less than C++11 are not supported."
    #error "C++ versions less than C++11 are not supported."
     ^
    /Users/username/Workspace/abseil-cpp/absl/base/internal/strerror.cc:49:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
      auto ret = strerror_r(errnum, buf, buflen);
    

    参考C++11 is not supported
    有人的回答——The problem here is not that you are trying to use C++11 but exactly the opposit, the source code depends on it (judging by the error given for auto res = test(); which is a C++11 feature).

    For GCC 5.4 the default C++ standard is C++98 with GNU extensions, as stated in the documentation, although you can explicitly set the C++11 standard (which is almost fully supported in GCC 5.4) using the -std=c++11 flag. This would probably solve the issue however updating to GCC 7.1 (as Mark Setchell advised) is much better idea and solves the issue out of the box (the default standard in 7.1 is C++14 with GNU extensions).

    As for how to pass the flag: you only need to add set(CMAKE_CXX_FLAGS "-std=c++11") to the beginning of the CMakeLists.txt or add a string entry in CMake GUI where the name is CMAKE_CXX_FLAGS and the value is -std=c++11.

    这种情况应该是代码中使用了C++11特性,要求必须使用C++11编译,而系统中GCC默认使用C++98特性,所以在CMakeLists.txt中开头处加上set(CMAKE_CXX_FLAGS "-std=c++11")这一句即可。实测有效。

    3.抽取头文件和静态库
    todo

    相关文章

      网友评论

          本文标题:安装并使用absl/abseil

          本文链接:https://www.haomeiwen.com/subject/cxnzwhtx.html