Cocos2d-x3.1 工程Xcode6编译时的问题

前端之家收集整理的这篇文章主要介绍了Cocos2d-x3.1 工程Xcode6编译时的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

最近遇到的问题,是我同事找到的解决办法,这里记录一下

报错

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)

Undefined symbols for architecture x86_64:
  "_opendir$INODE64",referenced from:
      _OPENSSL_DIR_read in libcocos2dx iOS.a(o_dir.o)
  "_readdir$INODE64",referenced from:
      _OPENSSL_DIR_read in libcocos2dx iOS.a(o_dir.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command Failed with exit code 1 (use -v to see invocation)

解决方案:

extern "C"
{
    
    //新增代码
#if defined (__unix) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#ifndef __ENABLE_COMPATIBILITY_WITH_UNIX_2003__
#define __ENABLE_COMPATIBILITY_WITH_UNIX_2003__
#include <stdio.h>
#include <dirent.h>
    FILE *fopen$UNIX2003( const char *filename,const char *mode )
    {
        return fopen(filename,mode);
    }
    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);
    }
    
    DIR *opendir$INODE64(const char * a)
    {
        return opendir(a);
    }
    
    struct dirent *readdir$INODE64(DIR *dir)
    {
        return readdir(dir);
    }
    
#endif
#endif
    //结束

#include "png.h"
#include "tiffio.h"
#include "base/etc1.h"
#include "jpeglib.h"
}

猜你在找的Cocos2d-x相关文章