简体   繁体   中英

error build cocos2dx android

I build cocos2d-x android project on windows 7.

$. / Build_native.sh - run, and the process falls on

Compile++ thumb  : cocos2dx_static <= CCFileUtilsAndroid.cpp
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp: In  member function 'virtual bool cocos2d::CCFileUtilsAndroid::isFileExist(const string&)':
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:88:9: error: 'FILE' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:88:15: error: 'fp' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:88:50: error: 'fopen' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:92:22: error: 'fclose' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp: In member function 'virtual unsigned char* cocos2d::CCFileUtilsAndroid::getFileData(const char*, const char*, long unsigned int*)':
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:133:13: error: 'FILE' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:133:19: error: 'fp' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:133:50: error: 'fopen' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:137:32: error: 'fseek' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:138:28: error: 'ftell' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:141:62: error: 'fread' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:142:22: error: 'fclose' was not declared in this scope
/cygdrive/d/work/Android/android-ndk-r8-crystax-1/build/core/build-binary.mk:320: recipe for target `obj/local/armeabi/objs/cocos2dx_static/platform/android/CCFileUtilsAndroid.o' failed

ScreenShot : http://joxi.ru/wy6OUdg5CbBkfuw7mZ4

How to fix it to build the project on?

Seems the Cocos2d-x code is not including the cstdio header where those things are declared. To fix this, edit the CCFileUtilsAndroid.cpp file and add the line

#include <cstdio>

up there at the top with the other includes. Now all those f* functions and FILE should be found.

have you solved this problem? Arleryd's solution worked for me, and the later error you post could be solved by this:

import the C:\\cocos2d-x-2.2.0\\cocos2dx\\platform\\android to eclipse, then done. see this:

http://www.cocos2d-x.org/wiki/How_to_set_up_the_android_cocos2d-x_development_environment_on_Windows_7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM