Undefined symbols for architecture armv7

简介:

This problem has been driving me crazy, and i can't work out how to fix it...

    Undefined symbols for architecture armv7: "_deflateEnd", referenced from: -[ASIDataCompressor closeStream] in ASIDataCompressor.o "_OBJC_CLASS_$_ASIDataDecompressor", referenced from: objc-class-ref in ASIHTTPRequest.o "_deflate", referenced from: -[ASIDataCompressor compressBytes:length:error:shouldFinish:] in ASIDataCompressor.o "_deflateInit2_", referenced from: -[ASIDataCompressor setupStream] in ASIDataCompressor.o ld: symbol(s) not found for architecture armv7 collect2: ld returned 1 exit status Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

I think it has to do with:

ld: symbol(s) not found for architecture armv7

but I have added: libz.1.2.3.dylib and it's not helping, anyone got any ideas?

share |improve this question
 

28 Answers

up vote 249down voteaccepted

Common Causes

The common causes for "Undefined symbols for architecture armv7" are:

  1. You import a header and do not link against the correct library. This is common, especially for headers for libraries like QuartzCore since it is not included in projects by default. To resolve:

    • Add the correct libraries in the Link Binary With Libraries section of the Build Phases.

    • If you want to add a library outside of the default search path you can include the path in the Library Search Paths value in the Build Settings and add 
      -l{library_name_without_lib_and_suffix} (eg. for libz.a use -lz) to the Other Linker Flags section of Build Settings.

  2. You copy files into your project but forgot to check the target to add the files to. To resolve:

    • Open the Build Phases for the correct target, expand Compile Sources and add the missing .m files. If this is your issue please upvote Cortex's answer below as well.

  3. You include a static library that is built for another architecture like i386, the simulator on your host machine. To resolve:

    • If you have multiple library files from your libraries vendor to include in the project you need to include the one for the simulator (i386) and the one for the device (armv7 for example).

    • Optionally, you could create a fat static library that contains both architectures.

 


Original Answer:

You have not linked against the correct libz file. If you right click the file and reveal in finder its path should be somewhere in an iOS sdk folder. Here is mine for example

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib

I recommend removing the reference and then re-adding it back in the Link Binary With Libraries section Build Phases of your target.

share |improve this answer
 
2  
It may also be because you need to add the word "-licucore" in project settings / Other Linker Flags. It was added automatically for my debug build but not the release one so wouldn't compile. –  JulianB Nov 2 '11 at 23:25 
3  
I had the same issue. Didn't really read the install notes properly so hadn't noticed that the new version of bugsense needs libz binary added in the build phases. –  Max MacLeod Nov 8 '12 at 9:33
    
This is by far the most useful post on StackOverflow! Thank You! –  Asciant Apr 7 '13 at 0:23
    
Are you sure that you've included an @implementation section in your respective .m file for all classes you've declared in your header file? –  slcott Jun 13 '13 at 2:27
2  
I just want to add I think it was really respectful of you to reference another answer to this question and tell us to up vote it if that helped. –  Andrew Sep 16 '13 at 0:03

I had a similar issue last night and the problem, was related to the fact that I had dragged a class from the Finder to my project in Xcode.

The solution was to go the the Build Phases tab and then the Compile Sources and make sure you drag the class to the list.

share |improve this answer
 
34  
THANK YOU! (How is XCode allowed to be this crap?) –  Reuben Scratton May 9 '12 at 18:30
1  
I owe my sanity to you –  Julian Coltea Jul 23 '12 at 18:48
3  
I wish I had realized this was the answer I was looking for earlier- Alternatively you can make sure to check 'Add to targets' when copying classes. –  T. Markle Aug 22 '12 at 4:33 
1  
And another life saved! I would like to express my deepest gratitude! –  Eduardo Nov 13 '12 at 10:00
1  
Another way to fix this is select file that is said to be missing. and open the "Utilities" slide out bar. (Thats the far right one) And choose the "File Inspector". Then make sure there is a check in the project under "Target Membership". I'm using Xcode 4.6.2 –  zingle-dingle May 7 '13 at 16:57

I had a similar issue and I had to check "Build Active Architecture Only" on each of the Project configurations (Debug, Release and Deployment) and in the Build Settings of the Target.

share |improve this answer
 
1  
Also did the trick for me. Was just needed in the main project though. –  Kirualex Oct 10 '12 at 10:20
    
it works for me! Thanks –  VietHung Mar 31 at 3:42

Another possible cause of "undefined symbol" linker errors is attempting to call a C function from a .mm file. In this case you'll need to use extern "C" {...} when you import the header files.

Linker error calling C-Function from Objective-C++

share |improve this answer
 
    
You save me!!!! –  alexqinbj May 21 '13 at 3:00

I had a similar issue with that. The class name after _OBJC_CLASS_$_ was actually my class. The reason was I didn't tick "Add to Target" when I drag the source code files into navigation list.

My solution was:

  1. delete the class from the navigation list and choose "remove reference only"

  2. drag the source code files again and make sure the tick box for "add to Target" is ticked. The tick box is just under "Copy if needed" and "Create group".

share |improve this answer
 
    
Just to add: although this is NOT THE MOST COMMON CAUSE of the error, I just your answer (didn't tick the box) happen to me now. –  Adam Jun 28 '12 at 12:06

There is usually a alias without the version identifier that is linked to the current version, in this case libz.dylib is linked to libz.1.2.5.dylib. Use the base alias instead of the versioned one.

share |improve this answer
 

Under Target -> Build Settings -> Apple LLVM compiler language: setting 'C++ Language Dialect' and 'C++ Standard Library' to Compiler default helped solve it.

share |improve this answer
 

I ran into this error when working with Google Maps framework. Under the "Build Settings" tab for the project, try changing/toggling "Build Active Architecture Only" from Yes to No after changing framework configurations. This was a small quirky trick that worked for me.

enter image description here

share |improve this answer
 

http://stackoverflow.com/a/10415850/1092219 Check My answer from the above link I have an similar problem that are solved with me by doing some steps that are be written in the above link try it i think you should get benefited.:)

share |improve this answer
 

if you're dealing with the iOS5 upgrade, I found that for compiling a project written to target 4.3, I could just rename libz.1.2.3.dynlib in the Project Navigator to libz.1.2.5.dynlib and it compiled.

My iPhoneOS50SDK/usr/lib folder has no libz.1.2.3.dynlib--don't know whether it's a beta thing or just natural upgrade.

share |improve this answer
 
 
欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 330987132 | Go:217696290 | Python:336880185 | 做人要厚道,转载请注明出处!
相关文章
|
弹性计算
云平台分为三种类型IaaS, PaaS和SaaS
云平台分为三种类型IaaS, PaaS和SaaS
2968 0
|
资源调度
umi中AssertionError [ERR_ASSERTION]: filePath not found of
umi中AssertionError [ERR_ASSERTION]: filePath not found of
|
存储 SQL Apache
Apache Doris 助力网易严选打造精细化运营 DMP 标签系统
Apache Doris 助力网易严选打造精细化运营 DMP 标签系统
699 0
|
算法 计算机视觉
opencv图像形态学
图像形态学是一种基于数学形态学的图像处理技术,它主要用于分析和修改图像的形状和结构。
250 4
|
人工智能 算法 数据挖掘
StoryTeller:字节、上海交大、北大共同推出的全自动长视频描述生成一致系统
StoryTeller是由字节跳动、上海交通大学和北京大学共同推出的全自动长视频描述生成系统。该系统通过音频视觉角色识别技术,结合低级视觉概念和高级剧情信息,生成详细且连贯的视频描述。StoryTeller在MovieQA任务中展现出比现有模型更高的准确率,适用于电影制作、视频内容分析、辅助视障人士等多个应用场景。
593 0
StoryTeller:字节、上海交大、北大共同推出的全自动长视频描述生成一致系统
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp微信小程序的大学生心理健康管理系统的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的大学生心理健康管理系统的详细设计和实现
292 0
|
监控 NoSQL Redis
Redis分区容错秘诀:解密主从模式
Redis主从模式用于提高高可用性、负载均衡和数据备份。主节点处理写入,从节点复制数据并分担读取,实现故障切换和读写分离。配置主从关系后,从节点连接主节点进行全量和增量复制。当主节点故障,从节点可接管服务。然而,主从延迟和数据不一致性是挑战,可通过优化网络、使用Sentinel和Redis Cluster等解决。关注“软件求生”获取更多内容。
391 1
Redis分区容错秘诀:解密主从模式
|
机器学习/深度学习 人工智能 自然语言处理
【论文精读】AAAI 2022 - Unified Named Entity Recognition as Word-Word Relation Classification
到目前为止,命名实体识别(NER)已经涉及三种主要类型,包括扁平、重叠(又名嵌套)和不连续NER,它们大多是单独研究的。
494 0
【论文精读】AAAI 2022 - Unified Named Entity Recognition as Word-Word Relation Classification
|
Java 数据库连接 mybatis
MyBatis 是否支持延迟加载?怎么实现?什么时候启用?
MyBatis 是否支持延迟加载?怎么实现?什么时候启用?
329 0
|
Java Maven 数据安全/隐私保护
Could not transfer artifact from/to Authentication failed for 401 Unauthorized
Could not transfer artifact from/to Authentication failed for 401 Unauthorized
823 0