gpt4 book ai didi

c++ - 无法将 C++ 与 Xcode 5 链接起来

转载 作者:行者123 更新时间:2023-11-28 02:57:04 25 4
gpt4 key购买 nike

所以我有这个遗留项目,我正试图将它带到 iOS 7 和 Xcode 5 中。这里所说的遗留,是指真正的遗留。就像 2004 年的遗产。

无论如何,我正在尝试构建这个东西,它吐出一些库,包括一些常见的第三方库。链接时,出现如下错误:

Undefined symbols for architecture ${arch}:
"google::protobuf::internal::WireFormatLite::WriteBytes(int, std::string const&, google::protobuf::io::CodedOutputStream*)"

在使用 nm 检查时,仍然包含在项目中的旧(仅限 arm)二进制库包含以下内容:

         U __ZN6google8protobuf8internal14WireFormatLite10WriteBytesEiRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEPNS0_2io17CodedOutputStreamE
00000a8c T __ZN6google8protobuf8internal14WireFormatLite10WriteBytesEiRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEPNS0_2io17CodedOutputStreamE
00002b28 S __ZN6google8protobuf8internal14WireFormatLite10WriteBytesEiRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEPNS0_2io17CodedOutputStreamE.eh</code>

当我通过 Xcode 5(因此,clang/llvm)运行项目时创建的新库(通用)包含以下内容:

         U __ZN6google8protobuf8internal14WireFormatLite10WriteBytesEiRKSsPNS0_2io17CodedOutputStreamE
00000514 T __ZN6google8protobuf8internal14WireFormatLite10WriteBytesEiRKSsPNS0_2io17CodedOutputStreamE
00000b2c S __ZN6google8protobuf8internal14WireFormatLite10WriteBytesEiRKSsPNS0_2io17CodedOutputStreamE.eh

对我来说,似乎在错位的名称中缺少参数。

这正常吗,我需要去别的地方看看吗?

或者如果这是问题所在:知道如何解决吗?

编辑:我混淆了旧的和新的。我没有改变原来的帖子

最佳答案

旧的,只有 ARM 的图书馆似乎表明:

google::protobuf::internal::WireFormatLite::WriteBytes(int, std::string const&, google::protobuf::io::CodedOutputStream*)

它具有使用 libstdc++ 编译的所有特征。

新的通用库表明:

google::protobuf::internal::WireFormatLite::WriteBytes(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)

这具有使用 libc++ 编译的所有特征

您的链接错误表明查找有问题:

 google::protobuf::internal::WireFormatLite::WriteBytes(int, std::string const&, google::protobuf::io::CodedOutputStream*)

如果链接到库的代码是使用 libstdc++ 编译的,并且因为您的新通用库是使用 libc++ 编译的,代码将不会链接。

您必须使用相同的 libc++/libstdc++ 支持编译一切,您不能混合搭配,因为它们会拒绝链接。确保项目中的每个元素都是使用相同的 C++ 标准库编译的,并且应该解决链接错误。

通常,分解符号(使用 c++filt)可以让您看到正确的签名,对于此代码,一旦您开始看到 std::__1:: 在符号中,它表示该库是使用 libc++ 编译的,当您看到链接失败时带有未修饰的 std:: 符号(即没有内部 __1::),那么它表明执行链接的项目正在使用 libstdc++

关于c++ - 无法将 C++ 与 Xcode 5 链接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21740425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com