2012-01-07 70 views
7

當我編譯我的cocos2d MAC項目中,我得到這個錯誤: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) 

回答

39

您需要的libz.dylib庫添加到您的目標。

從Xcode 4.6開始,這非常簡單。目標摘要屏幕允許您添加和刪除框架和庫。這裏有一個演示:

adding a library to a target in Xcode 4.6 and later

+1

找到了這個,並幫助我 - 現在圖書館被稱爲「libz.tbd」 – Maxxx 2015-12-04 12:09:53

22

打開目標的構建設置。找到其他連接器標誌設置。添加-lz標誌。

您不需要像Rob建議的那樣將libz.dylib添加爲框架,儘管這也適用。

+0

當試圖使用cocos2d靜態庫建立一個項目時,像一個魅力工作。 – diegoreymendez 2013-03-24 16:05:56

+1

也適用於Cocos2d(模板)作爲源。 (注意:花栗鼠來源必須是'-f-objc-no-arc'-ed。) – Olie 2014-07-30 22:00:13