cocos2d-x3.3 以前版本 工程Xcode6编译时的问题

时间:2022-03-03 05:24:05
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 (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 (use -v to see invocation)

编译在xcode 6.x前没有问题, 在xcode6.x就出现以上报错

解决办法就是在appDelegate.cpp 里面添加一下代码

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
}