Undefined symbols _fwrite$UNIX2003

在使用crossApp的时候出现了这个问题,Undefined symbols _fwrite$UNIX2003,因为是cocos2d的内核,所以搜索了下,发现有的时候cocos2d-x也会出现这种问题。

类似的错误报错如下:

Undefined symbols for architecture i386:
  "_fwrite$UNIX2003", referenced from:
      _unixErrorHandler in libcocos2dx iOS.a(tif_unix.o)
      _unixWarningHandler in libcocos2dx iOS.a(tif_unix.o)
      _empty_output_buffer in libcocos2dx iOS.a(jdatadst.o)
      _term_destination in libcocos2dx iOS.a(jdatadst.o)
      _Fax3PrintDir in libcocos2dx iOS.a(tif_fax3.o)
      _PredictorPrintDir in libcocos2dx iOS.a(tif_predict.o)
  "_strerror$UNIX2003", referenced from:
      _TIFFOpen in libcocos2dx iOS.a(tif_unix.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决办法:

在AppDelegate.cpp的最后面添加下面代码:

extern "C"{
    size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
    {
        return fwrite(a, b, c, d);
    }
    char* strerror$UNIX2003( int errnum )
    {
        return strerror(errnum);
    }
}

参考文章:
http://blog.ready4go.com/blog/2014/06/06/xcode6-beta-build-fix/
http://stackoverflow.com/questions/8732393/code-coverage-with-xcode-4-2-missing-files

Last modification:January 1st, 1970 at 08:00 am
如果看了这个文章可以让你少加会班,可以请我喝杯可乐
已打赏名单
微信公众号

Leave a Comment