首页 > 代码库 > Cocos2dx 3.x iOS工程编译ERROR!

Cocos2dx 3.x iOS工程编译ERROR!

Error:

技术分享

在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);            }    }

使用libcrul库,并用5s或6模拟器编译(估计是64位处理器的机子):
Error:
技术分享

在工程目录cocos2dx/cocos/platform目录中,修改CCImage.cpp文件:

首先找到代码:
extern "C"{#include "png.h"#include "tiffio.h"#include "base/etc1.h"#include "jpeglib.h"}

 在代码中添加如下代码:

#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

 如图:

 1 extern "C" 2 { 3 #include "png.h" 4 #include "tiffio.h" 5 #include "base/etc1.h" 6 #include "jpeglib.h" 7 #if defined (__unix) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) 8 #ifndef __ENABLE_COMPATIBILITY_WITH_UNIX_2003__ 9 #define __ENABLE_COMPATIBILITY_WITH_UNIX_2003__10 #include <stdio.h>11 #include <dirent.h>12     FILE *fopen$UNIX2003( const char *filename, const char *mode )13     {14         return fopen(filename, mode);15     }16     size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )17     {18         return fwrite(a, b, c, d);19     }20     char *strerror$UNIX2003( int errnum )21     {22         23         return strerror(errnum);24     }25     26     DIR *opendir$INODE64(const char * a)27     {28         return opendir(a);29     }30     31     struct dirent *readdir$INODE64(DIR *dir)32     {33         return readdir(dir);34     }35     36 #endif37 #endif38 }

 

 

 

Cocos2dx 3.x iOS工程编译ERROR!