美文网首页
Protobuf的一个链接错误

Protobuf的一个链接错误

作者: devzhaoyou | 来源:发表于2018-06-28 09:37 被阅读93次

    Xcode 中编译protobuf, 编译没有问题,上层库链接protobuf库的时候报6链接错误 :

    clang: warning: libstdc++ is deprecated; move to libc++ [-Wdeprecated]
    Undefined symbols for architecture x86_64:
      "cloopen_google::protobuf::io::StringOutputStream::StringOutputStream(std::string*)", referenced from:
          VideoSenderStatisticsInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          VideoReceiverStatisticsInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          AudioSenderStatisticsInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          AudioReceiverStatisticsInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          MediaStatisticsInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          MediaStatisticsDataInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          UserAuthRespInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(UserAuthResp.pb.o)
          ...
      "cloopen_google::protobuf::internal::WireFormatLite::ReadString(cloopen_google::protobuf::io::CodedInputStream*, std::string*)", referenced from:
          VideoSenderStatisticsInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          VideoReceiverStatisticsInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          AudioSenderStatisticsInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          AudioReceiverStatisticsInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          MediaStatisticsDataInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          UserAuthRespInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(UserAuthResp.pb.o)
          ServerAddr::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(UserAuthResp.pb.o)
          ...
      "cloopen_google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, cloopen_google::protobuf::io::CodedOutputStream*)", referenced from:
          MsgLiteInner::SerializeWithCachedSizes(cloopen_google::protobuf::io::CodedOutputStream*) const in libCCPiPhoneSDK_Mac.a(MsgLite.pb.o)
      "cloopen_google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, cloopen_google::protobuf::io::CodedOutputStream*)", referenced from:
          VideoSenderStatisticsInner::SerializeWithCachedSizes(cloopen_google::protobuf::io::CodedOutputStream*) const in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          VideoReceiverStatisticsInner::SerializeWithCachedSizes(cloopen_google::protobuf::io::CodedOutputStream*) const in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          AudioSenderStatisticsInner::SerializeWithCachedSizes(cloopen_google::protobuf::io::CodedOutputStream*) const in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          AudioReceiverStatisticsInner::SerializeWithCachedSizes(cloopen_google::protobuf::io::CodedOutputStream*) const in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          MediaStatisticsDataInner::SerializeWithCachedSizes(cloopen_google::protobuf::io::CodedOutputStream*) const in libCCPiPhoneSDK_Mac.a(MediaStatisticsData.pb.o)
          UserAuthRespInner::SerializeWithCachedSizes(cloopen_google::protobuf::io::CodedOutputStream*) const in libCCPiPhoneSDK_Mac.a(UserAuthResp.pb.o)
          ServerAddr::SerializeWithCachedSizes(cloopen_google::protobuf::io::CodedOutputStream*) const in libCCPiPhoneSDK_Mac.a(UserAuthResp.pb.o)
          ...
      "cloopen_google::protobuf::internal::WireFormatLite::ReadBytes(cloopen_google::protobuf::io::CodedInputStream*, std::string*)", referenced from:
          MsgLiteInner::MergePartialFromCodedStream(cloopen_google::protobuf::io::CodedInputStream*) in libCCPiPhoneSDK_Mac.a(MsgLite.pb.o)
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    排查:
    函数所在实现文件已经编译进去,函数也没有被宏控制漏编;
    奇怪,
    最终排查原因:
    protobuf 工程设置中 C++ Standard Library 设置的为 LLVM 的 libc++, 上层库编译使用的为GNU 实现的 libstdc++ , 两者设置为一致,链接OK!

    protobuf 工程编译设置

    其实从编译器报错第一句大致也能看出端倪

    clang: warning: libstdc++ is deprecated; move to libc++ 
    

    不赞成用libstdc++,基本就是这块的问题。看来LLVM和GNU两套实现的c++标准库还是不要混用!

    相关文章

      网友评论

          本文标题:Protobuf的一个链接错误

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