架构armv7的未定义符号 [英] Undefined symbols for architecture armv7

查看:109
本文介绍了架构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

我认为这与:

ld: symbol(s) not found for architecture armv7

但我添加了: li bz.1.2.3.dylib 并且它没有帮助,任何人都有任何想法?

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

推荐答案

普通原因



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

Common Causes

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


  1. 导入标题但未链接到正确的库。这很常见,特别是对于像QuartzCore这样的库的头文件,因为默认情况下它不包含在项目中。解决:

  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.

如果要在默认搜索路径之外添加库,可以在 库搜索中包含路径构建设置中的路径 值并添加
-l {library_name_without_lib_and_suffix} (例如,对于libz) .a使用 -lz )到 其他链接器标志 构建设置的部分

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.

将文件复制到项目中但忘记检查目标以将文件添加到。解决:


  • 打开 构建阶段 为正确的目标,展开 编译来源 并添加缺少的 .m 个文件。如果这是您的问题,请同时提升 Cortex的答案


  • 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.

包含为其他架构构建的静态库,例如主机上的模拟器i386。要解决:

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


  • 如果您的库供应商有多个库文件要包含在项目中,则需要包含模拟器(i386)和设备(例如armv7)。

  • 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.


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

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

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

我建议删除引用,然后将其重新添加回Link Binary With Libraries部分Build target of target。

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

这篇关于架构armv7的未定义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆