一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

IOS开发时遇到Undefined symbols for architecture解决两例(微信及高德地图)

时间:2022-11-14 22:13:52 编辑:袖梨 来源:一聚教程网

微信开发WeChatSDK报Undefined symbols for architecture x86_64错误

今天在写iOS项目时,需要用到微信登陆模块,所以引入了微信官方的iOS SDK,但是编译时一直出Mach-O的错误,怀疑是SDK本身的问题。于是建了个新的空项目,导入WeChatSDK,依旧报错,报错内容一致:

Undefined symbols for architecture x86_64:
"operator delete[](void*)", referenced from:
+[WeChatApiUtil EncodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
+[WeChatApiUtil NsDataEncodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
+[WeChatApiUtil DecodeWithBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
+[WeChatApiUtil DecodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
"operator new[](unsigned long)", referenced from:
+[WeChatApiUtil EncodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
+[WeChatApiUtil NsDataEncodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
+[WeChatApiUtil DecodeWithBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
+[WeChatApiUtil DecodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in AppDelegate.o
Dwarf Exception Unwind Info (__eh_frame) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

经研究,加入libc++.dylib可解决问题。

具体方法是:打开工程的属性窗口,在Build Phases的Link Binary With Libraries里面添加libc++.dylib

http://ilovetile.com/wp-content/uploads/2015/04/QQ20150409-1@2x.png


iOS开发错误:Undefined symbols for architecture i386 解决方案


在做高德地图SDK时,碰到了一个错误:


ld: warning: ignoring file /iOS-Dev/MyDiary/Release-iphoneos/libMAMapKit.a, missing required architecture i386 in file /iOS-Dev/MyDiary/Release-iphoneos/libMAMapKit.a (2 slices)

Undefined symbols for architecture i386:

“_OBJC_CLASS_$_MAMapView”, referenced from:

objc-class-ref in LocationViewController.o

ld: symbol(s) not found for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)



Undefined symbols for architecture i386

网络上所说的添加library,添加头文件 ,添加.m文件 ,添加framework都添加了。问题依旧。回想我在真机上测试是没有问题的。就是在模拟器上测试时出现这个问题。那是不是和平台有关呢?记得当时copy到项目文件夹中的两个文件如下:


release

很容易理解,一个是真机上的测试,一个是模拟器上的测试。是这个原因造成的吗?

查看”library search path”:


library search path

我们看到,模拟器在最后一个,如果我们调换一下顺序会怎么样?测试一下:


library search path2

然后我们编译。哇,竟然成功了。


Compile success


热门栏目