Clang:找不到符号。 cocos2d mac

时间:2012-01-07 07:54:53

标签: objective-c xcode macos cocos2d-iphone clang

当我编译我的cocos2d mac项目时,我收到此错误:

Undefined symbols for architecture x86_64:
"_inflateInit2_", referenced from:
  _ccInflateMemoryWithHint in ZipUtils.o
"_inflate", referenced from:
  _ccInflateMemoryWithHint in ZipUtils.o
"_inflateEnd", referenced from:
  _ccInflateMemoryWithHint in ZipUtils.o
"_gzopen", referenced from:
  _ccInflateGZipFile in ZipUtils.o
"_gzread", referenced from:
  _ccInflateGZipFile in ZipUtils.o
"_gzclose", referenced from:
  _ccInflateGZipFile in ZipUtils.o
"_uncompress", referenced from:
  _ccInflateCCZFile in ZipUtils.o

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

2 个答案:

答案 0 :(得分:39)

您需要将libz.dylib库添加到目标。

从Xcode 4.6开始,这非常简单。目标摘要屏幕允许您添加和删除框架和库。这是一个演示:

adding a library to a target in Xcode 4.6 and later

答案 1 :(得分:22)

打开目标的构建设置。找到其他链接标记设置。添加 -lz 标志。

你不需要像Rob建议的那样将libz.dylib添加为框架,尽管这也有效。