在 Xcode 6.3 中使用 Boost C++?
Posted
技术标签:
【中文标题】在 Xcode 6.3 中使用 Boost C++?【英文标题】:Use Boost C++ in Xcode 6.3? 【发布时间】:2015-06-29 08:17:41 【问题描述】:Undefined symbols for architecture x86_64:
"boost::serialization::typeid_system::extended_type_info_typeid_0::type_register (std::type_info const&)", referenced from:
boost::serialization::extended_type_info_typeid<std::__1::pair<long long const, long long> >::extended_type_info_typeid() in TestC.o
boost::serialization::extended_type_info_typeid<std::__1::map<long long, long long, std::__1::less<long long>, std::__1::allocator<std::__1::pair<long long const, long long> > > >::extended_type_info_typeid() in TestC.o
"boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister()", referenced from:
boost::serialization::extended_type_info_typeid<std::__1::pair<long long const, long long> >::~extended_type_info_typeid() in TestC.o
boost::serialization::extended_type_info_typeid<std::__1::map<long long, long long, std::__1::less<long long>, std::__1::allocator<std::__1::pair<long long const, long long> > > >::~extended_type_info_typeid() in TestC.o
"boost::serialization::typeid_system::extended_type_info_typeid_0::extended_type_info_typeid_0(char const*)", referenced from:
boost::serialization::extended_type_info_typeid<std::__1::pair<long long const, long long> >::extended_type_info_typeid() in TestC.o
boost::serialization::extended_type_info_typeid<std::__1::map<long long, long long, std::__1::less<long long>, std::__1::allocator<std::__1::pair<long long const, long long> > > >::extended_type_info_typeid() in TestC.o
"boost::serialization::typeid_system::extended_type_info_typeid_0::~extended_type_info_typeid_0()", referenced from:
boost::serialization::extended_type_info_typeid<std::__1::pair<long long const, long long> >::~extended_type_info_typeid() in TestC.o
boost::serialization::extended_type_info_typeid<std::__1::pair<long long const, long long> >::extended_type_info_typeid() in TestC.o
boost::serialization::extended_type_info_typeid<std::__1::map<long long, long long, std::__1::less<long long>, std::__1::allocator<std::__1::pair<long long const, long long> > > >::~extended_type_info_typeid() in TestC.o
boost::serialization::extended_type_info_typeid<std::__1::map<long long, long long, std::__1::less<long long>, std::__1::allocator<std::__1::pair<long long const, long long> > > >::extended_type_info_typeid() in TestC.o
我将 Boost C++ 库用于我的 Objective-C 项目。我按照此说明为 Xcode 添加了增强功能:http://freddy.cellcore.org/post/79587278354/boost-c-libraries-on-osx-xcode-5 添加 boost.framework 后,我可以正确地包含标题。
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/map.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
但是当我添加如下几行代码时,按构建,它会显示上面的错误。
std::map<int64_t, int64_t> foo;
boost::filesystem::path myFile = boost::filesystem::current_path() / "myfile.dat";
if (filesystem::exists(myFile))
filesystem::ifstream ifs(myFile/*.native()*/);
archive::text_iarchive ta(ifs);
ta >> foo; // foo is empty until now, it's fed by myFile
std::cout << "Read " << foo.size() << " entries from " << myFile << "\n";
else
for (int i=0; i<100; ++i) foo[i] = 10;
filesystem::ofstream ofs(myFile/*.native()*/);
archive::text_oarchive ta(ofs);
ta << foo; // foo is empty until now, it's fed by myFile
std::cout << "Wrote " << foo.size() << " random entries to " << myFile << "\n";
我该如何解决这个问题?
【问题讨论】:
【参考方案1】:我无法再访问那个 Github 页面,但我猜你只有 x86 版本,而不是 x64 版本。
Try this...
来自脚本:
# To configure the script, define:
# BOOST_LIBS: which libraries to build
# IPHONE_SDKVERSION: iPhone SDK version (e.g. 5.1)
#
# Then go get the source tar.bz of the boost you want to build, shove it in the
# same directory as this script, and run "./boost.sh".
或者你可以试试这个版本?是预编译... https://github.com/danoli3/ofxiosBoost
【讨论】:
很遗憾,您提供的链接正是我在问题中添加的链接。 您在构建时将 BOOST_LIBS 设置为什么?以及哪个来源 tar.bz? 我只是在构建框架时保留shell脚本,它下载1.56.0 我编辑了我的答案 - iOS 有一个预编译的 64 位版本 非常感谢!我缺少将序列化放入 BOOST_LIBS以上是关于在 Xcode 6.3 中使用 Boost C++?的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Xcode 6.3 中使用 AutoLayout 创建 ScrollView
在 Xcode 6.3 (Swift) 中使用 Parse 和 Facebook 框架编译错误
如何在 Swift(Xcode 6.3)中翻转标签(获取镜像视图)