美文网首页
在Mac上编译Telegram-desktop遇到的问题

在Mac上编译Telegram-desktop遇到的问题

作者: 韬czt | 来源:发表于2017-07-15 09:31 被阅读0次

按照Official guide
一步步的去做

在编译openal-soft时,会遇到

/Users/choice/TBuild/Libraries/openal-soft/examples/alffplay.cpp:7:10: fatal error: 'condition_variable' file not found

的问题,
这是因为在执行cmake的时候,指定了OS X的系统最低支持为10.8,就是下面这句:

cmake -D LIBTYPE:STRING=STATIC -D CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.8 ..

解决方法:
注释掉openal-soft里面的CMakeLists.txt里面1534行

IF(FFVER_OK)

添加下述语句

SET(FFVER_OK FALSE)

附近,从而不编译这个文件即可

出现错误的原因:

在10.8 的时候默认使用的是gcc的libstdc++,但是这个版本特别老,不支持C++11的特性

验证,测试使用的C++11的程序如下:

#include <memory>

int main(int argc, char const* argv[])
{
  std::shared_ptr<int> intPtr = std::make_shared<int>(60);
  return 0;
}

分别使用如下命令,在mac os x 12上编译结果如下:

c++ test_std.cpp -std=c++11 -mmacosx-version-min=10.8
编译失败

错误信息中可以看到在10.9中开始使用libc++:

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9
test_std.cpp:5:8: error: no member named 'shared_ptr' in namespace 'std'
  std::shared_ptr<int> intPtr = std::make_shared<int>(60);
  ~~~~~^
test_std.cpp:5:22: error: expected '(' for function-style cast or type construction
  std::shared_ptr<int> intPtr = std::make_shared<int>(60);
                  ~~~^
test_std.cpp:5:24: error: use of undeclared identifier 'intPtr'
  std::shared_ptr<int> intPtr = std::make_shared<int>(60);
                       ^
test_std.cpp:5:38: error: no member named 'make_shared' in namespace 'std'
  std::shared_ptr<int> intPtr = std::make_shared<int>(60);
                                ~~~~~^
test_std.cpp:5:53: error: expected '(' for function-style cast or type construction
  std::shared_ptr<int> intPtr = std::make_shared<int>(60);
                                                 ~~~^
5 errors generated.

c++ test_std.cpp -std=c++11 -mmacosx-version-min=10.9
编译成功

c++ test_std.cpp -std=c++11
编译成功

参考:
https://stackoverflow.com/questions/2923502/what-does-macosx-version-min-imply
第二个回答
https://stackoverflow.com/questions/29175846/c11-headers-missing-on-mac-os-x-10-8-2-mountainlion

佐证:
https://stackoverflow.com/questions/23666754/default-to-lib-stdlibc-for-clang-on-mac-os-mavericks-with-xcode

相关文章

网友评论

      本文标题:在Mac上编译Telegram-desktop遇到的问题

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