2011年6月13日

iOS 5 beta SDK touble shooting

如果有用到libz.1.2.3.dylib這個framework(例如ASIHTTP)
iOS SDK升級到5 beta會遇到下列錯誤:
ld: library not found for -lz.1.2.3
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 failed with exit code 1
或是用了ASIHTTP:

 Undefined symbols for architecture armv7:
  "_crc32", referenced from:
      _unzReadCurrentFile in unzip.o
  "_inflateEnd", referenced from:
      _unzCloseCurrentFile in unzip.o
      -[ASIDataDecompressor closeStream] in ASIDataDecompressor.o
  "_inflate", referenced from:
      _unzReadCurrentFile in unzip.o
      -[ASIDataDecompressor uncompressBytes:length:error:] in ASIDataDecompressor.o
  "_deflateEnd", referenced from:
      -[ASIDataCompressor closeStream] in ASIDataCompressor.o
  "_get_crc_table", referenced from:
      _unzOpenCurrentFile3 in unzip.o
  "_inflateInit2_", referenced from:
      _unzOpenCurrentFile3 in unzip.o
      -[ASIDataDecompressor setupStream] in ASIDataDecompressor.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/llvm-g++-4.2 failed with exit code 1

是因為libz.1.2.3.dylib到iOS 5後就升級到libz.1.2.5了
一個方法是把專案Link Binary With Libraries裡的
如果怕拿到別的機器跑得再改一次,可以把新的libz link到舊的,不動到專案就可以直接跑了
在command line下指令:
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/libz.1.2.5.dylib /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/libz.1.2.3.dylib
另外,Xcode 4.2對SVN好像不支援自定的port?(如8080)
不知道什麼時候會修好,在這之前compare只好先用FileMerge和opendiff頂著先了

3 則留言:

S.T.Huang 提到...

你好,我試了你的方法作了還是無效耶

是到終端機把你只是的那三行貼上去 enter沒錯吧

第二次 終端機也指示說 file exist了

但是xcode 4.2還是老樣子

是我有哪部分出錯了嗎?

kenobiluh 提到...

後來學到一個比較好的做法:
把libz1.2.3.dylib改連結到libz.dylib,這樣應該會自動偵測版本了
希望有幫助

Unknown 提到...
作者已經移除這則留言。