解决Xcode 6 编译Cocos2d-x iOS项目失败

在Xcode 6 beta里编译Cocos2d-x iOS项目时可能会失败,提示如下错误:

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)

如下图所示:

解决Xcode 6 编译Cocos2d-x iOS项目失败
解决方法很简单,只需要在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);

    }

}
上一篇:分享个win平台cocos2d-x创建项目的快捷方式


下一篇:一个cocos2d-x的项目