xcode Clang:未找到符号。cocos2d mac

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8768224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:55:49  来源:igfitidea点击:

Clang: symbols not found. cocos2d mac

objective-cxcodemacoscocos2d-iphoneclang

提问by JqueryToAddNumbers

When i compile my cocos2d mac project i get this error:

当我编译我的 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)

回答by rob mayoff

You need to add the libz.dylib library to your target.

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

As of Xcode 4.6, this is very easy. The target summary screen lets you add and remove frameworks and libraries. Here's a demonstration:

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

adding a library to a target in Xcode 4.6 and later

在 Xcode 4.6 及更高版本中向目标添加库

回答by LearnCocos2D

Open your target's Build Settings. Locate the Other Linker Flagssetting. Add the -lzflag to it.

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

You don't need to add the libz.dylib as a framework as Rob suggests, although that works too.

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