iOS链接错误,Undefined symbols for architecture arm64:std::__1::basic_string<char, std::__1::char_traits<
2015-06-18 10:38
751 查看
最近在开发和iOS相关的程序,需要和C++混编,做了几个静态库,之后整个app整合一下,结果在整合过程中遇到问题,总是提示链接错误:
Undefined symbols for architecture arm64:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(unsigned long, char)", referenced from:
std::__1::wstring_convert<std::__1::codecvt_utf8<wchar_t, 1114111ul, (std::__1::codecvt_mode)0>, wchar_t, std::__1::allocator<wchar_t>, std::__1::allocator<char> >::to_bytes(wchar_t const*, wchar_t const*) in
librender_sketcher_x6b64usd.a(sketcher_helper.o)
"std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >::resize(unsigned long, wchar_t)", referenced from:
std::__1::wstring_convert<std::__1::codecvt_utf8<wchar_t, 1114111ul, (std::__1::codecvt_mode)0>, wchar_t, std::__1::allocator<wchar_t>, std::__1::allocator<char> >::from_bytes(char const*, char const*) in librender_sketcher_x6b64usd.a(sketcher_helper.o)
"std::exception_ptr::~exception_ptr()", referenced from:
std::__1::packaged_task<void ()>::operator()() in librender_sketcher_x6b64usd.a(thread_pool_impl-10874E7367B0837E.o)
...
一看是找不到c++相关符号的定义,搞了半天终于有所收获:
可以把app中的任何一个.m文件扩展名改为.mm,即可解决链接错误
亦或 在app的引用库中显示引用 libstdc++.dylib 也可解决此问题
其道理就是只要app中存在.mm文件则app会自动添加对c++库的引用
另外XCODE也有一个问题:我在app中使用NSClassFromString 进行反射时,被反射类在另外一个静态库中,并且该app没有包含该库对应类的头文件,反射后始终返回nil,必须在Build setting的Other link flag中加入-all_load选项才能反射成功
Undefined symbols for architecture arm64:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(unsigned long, char)", referenced from:
std::__1::wstring_convert<std::__1::codecvt_utf8<wchar_t, 1114111ul, (std::__1::codecvt_mode)0>, wchar_t, std::__1::allocator<wchar_t>, std::__1::allocator<char> >::to_bytes(wchar_t const*, wchar_t const*) in
librender_sketcher_x6b64usd.a(sketcher_helper.o)
"std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >::resize(unsigned long, wchar_t)", referenced from:
std::__1::wstring_convert<std::__1::codecvt_utf8<wchar_t, 1114111ul, (std::__1::codecvt_mode)0>, wchar_t, std::__1::allocator<wchar_t>, std::__1::allocator<char> >::from_bytes(char const*, char const*) in librender_sketcher_x6b64usd.a(sketcher_helper.o)
"std::exception_ptr::~exception_ptr()", referenced from:
std::__1::packaged_task<void ()>::operator()() in librender_sketcher_x6b64usd.a(thread_pool_impl-10874E7367B0837E.o)
...
一看是找不到c++相关符号的定义,搞了半天终于有所收获:
可以把app中的任何一个.m文件扩展名改为.mm,即可解决链接错误
亦或 在app的引用库中显示引用 libstdc++.dylib 也可解决此问题
其道理就是只要app中存在.mm文件则app会自动添加对c++库的引用
另外XCODE也有一个问题:我在app中使用NSClassFromString 进行反射时,被反射类在另外一个静态库中,并且该app没有包含该库对应类的头文件,反射后始终返回nil,必须在Build setting的Other link flag中加入-all_load选项才能反射成功
相关文章推荐
- iOS 复选框风格转换 Switchery 开关效果
- IOS项目自动生成技术文档
- iOS 静态代码扫描
- xmpp的一些常识
- iOS va_list,va_start,va_end
- iOS开发- iPhone6/6 Plus适配
- 上海iOS开发工资待遇如何?
- iOS开发关于后台的一些方法
- iOS开发系列--NextPrevious On-Demand Resource Basics
- iOS项目开发规范
- 所有iOS设备的屏幕分辨率
- xmpp-iOS-添加好友和删除好友
- MVVM框架实践IOS集锦
- 谈谈iOS中粘性动画以及果冻效果的实现
- IOS笔记051-手势使用
- 简单的iOS开发实例
- iOS屏幕旋转
- IOS开发--iOS核心动画
- iOS 基础学习(8)----iOS 新建一个对象
- SocketIO --- iOS使用篇