首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >架构armv7的未定义符号

架构armv7的未定义符号
EN

Stack Overflow用户
提问于 2011-06-22 01:33:18
回答 40查看 376.6K关注 0票数 314

这个问题快把我逼疯了,我不知道该怎么解决它……

代码语言:javascript
复制
    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

我认为这与以下内容有关:

代码语言:javascript
复制
ld: symbol(s) not found for architecture armv7

但我补充说:libz.1.2.3.dylib没有帮助,有人有什么想法吗?

EN

回答 40

Stack Overflow用户

回答已采纳

发布于 2011-06-22 01:38:31

常见原因

“架构armv7的未定义符号”的常见原因是:

  1. 导入了一个头文件,并且没有链接到正确的库。这很常见,特别是对于像QuartzCore这样的库的头文件,因为默认情况下它不包括在项目中。要解决:

代码语言:javascript
复制
- 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} (例如对于libz.a,使用Build Settings.的Other Linker Flags部分的-lz)

  1. 将文件复制到您的项目中,但忘记检查目标以将文件添加到中。要解决:

代码语言:javascript
复制
- 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](https://stackoverflow.com/a/10170293/418715) as well.

  1. 包括一个静态库,该静态库是为另一个架构构建的,如i386,即您主机上的模拟器。要解决:

代码语言:javascript
复制
- 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](https://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4) that contains both architectures.

原始答案:

您没有链接到正确的libz文件。如果您右键单击该文件并在finder中显示其路径,则其路径应该位于iOS sdk文件夹中的某个位置。下面是我的例子

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

我建议删除引用,然后将其重新添加到目标的Link Binary With Libraries部分的构建阶段。

票数 512
EN

Stack Overflow用户

发布于 2012-04-16 15:39:49

我昨晚遇到了类似的问题,这个问题与我将一个类从Finder拖到我的Xcode项目中有关。

解决方案是转到构建阶段选项卡,然后转到编译源,并确保将类拖到列表中。

票数 198
EN

Stack Overflow用户

发布于 2011-12-20 07:52:55

我遇到了类似的问题,我必须在每个项目配置(Debug、Release和Deployment)和Target的Build Settings中选中"Build Active Architecture Only“。

票数 37
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6429494

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档