问题1、
我的过程是这样的,我先建立了一个支持lua的cocos2d-x的项目,还没有写任何的代码,然后编译,说找不到cocos-ext.h这个文件,然后包含路径以及添加链接库,然后编译通过,但是执行的时候,出现了链接错误如下:
liblua.lib(tolua_to.obj):errorLNK2001:无法解析的外部符号_lua_pushnumber
1>CCLuaEngine.obj:errorLNK2019:无法解析的外部符号_lua_pushnumber,该符号在函数"public:virtualint__thiscallcocos2d::CCLuaEngine::executeLayerTouchesEvent(classcocos2d::CCLayer*,int,classcocos2d::CCSet*)"(?executeLayerTouchesEvent@CCLuaEngine@cocos2d@@UAEHPAVCCLayer@2@HPAVCCSet@2@@Z)中被引用
1>liblua.lib(CCLuaStack.obj):errorLNK2001:无法解析的外部符号_lua_pushnumber
1>liblua.lib(tolua_is.obj):errorLNK2001:无法解析的外部符号_lua_pushnumber
1>liblua.lib(tolua_push.obj):errorLNK2001:无法解析的外部符号_lua_pushnumber
1>CCLuaEngine.obj:errorLNK2019:无法解析的外部符号_lua_pushinteger,该符号在函数"public:virtualint__thiscallcocos2d::CCLuaEngine::executeLayerTouchesEvent(classcocos2d::CCLayer*,classcocos2d::CCSet*)"(?executeLayerTouchesEvent@CCLuaEngine@cocos2d@@UAEHPAVCCLayer@2@HPAVCCSet@2@@Z)中被引用
1>tolua_fix.obj:errorLNK2001:无法解析的外部符号_lua_pushinteger
1>liblua.lib(CCLuaStack.obj):errorLNK2001:无法解析的外部符号_lua_pushinteger
1>liblua.lib(tolua_event.obj):errorLNK2001:无法解析的外部符号_lua_createtable
1>CCLuaEngine.obj:errorLNK2019:无法解析的外部符号_lua_createtable,该符号在函数"public:virtualint__thiscallcocos2d::CCLuaEngine::executeLayerTouchesEvent(classcocos2d::CCLayer*,classcocos2d::CCSet*)"(?executeLayerTouchesEvent@CCLuaEngine@cocos2d@@UAEHPAVCCLayer@2@HPAVCCSet@2@@Z)中被引用
1>tolua_fix.obj:errorLNK2001:无法解析的外部符号_lua_createtable
1>liblua.lib(CCLuaStack.obj):errorLNK2001:无法解析的外部符号_lua_createtable
1>liblua.lib(tolua_map.obj):errorLNK2001:无法解析的外部符号_lua_createtable
1>CCLuaEngine.obj:errorLNK2019:无法解析的外部符号_lua_rawseti,该符号在函数"public:virtualint__thiscallcocos2d::CCLuaEngine::executeLayerTouchesEvent(classcocos2d::CCLayer*,classcocos2d::CCSet*)"(?executeLayerTouchesEvent@CCLuaEngine@cocos2d@@UAEHPAVCCLayer@2@HPAVCCSet@2@@Z)中被引用
1>liblua.lib(CCLuaStack.obj):errorLNK2001:无法解析的外部符号_lua_rawseti
1>liblua.lib(tolua_to.obj):errorLNK2001:无法解析的外部符号_lua_tolstring
1>Cocos2dxLuaLoader.obj:errorLNK2019:无法解析的外部符号_lua_tolstring,该符号在函数_cocos2dx_lua_loader中被引用
1>tolua_fix.obj:errorLNK2001:无法解析的外部符号_lua_tolstring
1>liblua.lib(CCLuaStack.obj):errorLNK2001:无法解析的外部符号_lua_tolstring
1>liblua.lib(tolua_is.obj):errorLNK2001:无法解析的外部符号_lua_tolstring
1>Cocos2dxLuaLoader.obj:errorLNK2019:无法解析的外部符号_luaL_checklstring,该符号在函数_cocos2dx_lua_loader中被引用
1>Cocos2dxLuaLoader.obj:errorLNK2019:无法解析的外部符号_luaL_error,该符号在函数_cocos2dx_lua_loader中被引用
1>liblua.lib(tolua_is.obj):errorLNK2001:无法解析的外部符号_luaL_error
1>liblua.lib(tolua_map.obj):errorLNK2001:无法解析的外部符号_luaL_error
1>Cocos2dxLuaLoader.obj:errorLNK2019:无法解析的外部符号_luaL_loadbuffer,该符号在函数_cocos2dx_lua_loader中被引用
1>liblua.lib(tolua_map.obj):errorLNK2001:无法解析的外部符号_luaL_loadbuffer
1>liblua.lib(tolua_map.obj):errorLNK2001:无法解析的外部符号_lua_gettop
1>liblua.lib(tolua_push.obj):errorLNK2001:无法解析的外部符号_lua_gettop
1>liblua.lib(tolua_to.obj):errorLNK2001:无法解析的外部符号_lua_gettop
1>liblua.lib(tolua_event.obj):errorLNK2001:无法解析的外部符号_lua_gettop
1>LuaCocos2d.obj:errorLNK2019:无法解析的外部符号_lua_gettop,该符号在函数"int__cdecltolua_Cocos2d_CCAffineTransformConcat00(structlua_State*)"(?tolua_Cocos2d_CCAffineTransformConcat00@@YAHPAUlua_State@@@Z)中被引用
1>tolua_fix.obj:errorLNK2001:无法解析的外部符号_lua_gettop
1>liblua.lib(CCLuaStack.obj):errorLNK2001:无法解析的外部符号_lua_gettop
1>liblua.lib(tolua_is.obj):errorLNK2001:无法解析的外部符号_lua_gettop
1>liblua.lib(tolua_event.obj):errorLNK2001:无法解析的外部符号_lua_touserdata
1>LuaCocos2d.obj:errorLNK2019:无法解析的外部符号_lua_touserdata,该符号在函数"int__cdecltolua_get_Cocos2d_kmMat4_mat(structlua_State*)"(?tolua_get_Cocos2d_kmMat4_mat@@YAHPAUlua_State@@@Z)中被引用
1>tolua_fix.obj:errorLNK2001:无法解析的外部符号_lua_touserdata
1>liblua.lib(tolua_map.obj):errorLNK2001:无法解析的外部符号_lua_touserdata
1>liblua.lib(tolua_to.obj):errorLNK2001:无法解析的外部符号_lua_touserdata
1>liblua.lib(tolua_map.obj):errorLNK2001:无法解析的外部符号_lua_pushstring
1>liblua.lib(tolua_push.obj):errorLNK2001:无法解析的外部符号_lua_pushstring
1>liblua.lib(tolua_event.obj):errorLNK2001:无法解析的外部符号_lua_pushstring
1>LuaCocos2d.obj:errorLNK2019:无法解析的外部符号_lua_pushstring,该符号在函数"int__cdecltolua_get_Cocos2d_kmMat4_mat(structlua_State*)"(?tolua_get_Cocos2d_kmMat4_mat@@YAHPAUlua_St
............
解决方法:
要加一个链接库就是lua51.lib
2、问题
make:execvp: /cygdrive/d/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-g++:Argument list too long
make: *** [obj/local/armeabi/libirrlichtbullet.so] Error 127
[/mw_shl_code]
解决:
路径参数过长,去掉多余路径
3、问题
Compile++ thumb : game_shared <= main.cpp
arm-linux-androideabi-g++.exe: error: CreateProcess: Nosuch file or directory
/cygdrive/c/development/android-ndk-r8c/build/core/build-binary.mk:263:recipe for target `obj/local/armeabi/objs/game_shared/hellocpp/main.o' Failed
解决:
路径参数过长,去掉多余路径
问题4、
1. jni/../../../cocos2dx/platform/android/CCCommon.cpp:Infunction'voidcocos2d::CCLog(charconst*,...)':
2. jni/../../../cocos2dx/platform/android/CCCommon.cpp:44:72:error:formatnotastringliteralandnoformatarguments[-Werror=format-security]
3. jni/../../../cocos2dx/platform/android/CCCommon.cpp:Infunction'voidcocos2d::CCLuaLog(charconst*)':
4. jni/../../../cocos2dx/platform/android/CCCommon.cpp:54:77:error:formatnotastringliteralandnoformatarguments[-Werror=format-security]
5. cc1plus:somewarningsbeingtreatedaserrors
6.
7. make:***[obj/local/armeabi/objs/cocos2dx_static/platform/android/CCCommon.o]Error1
解决:
[cpp]view plaincopy
1. APP_CPPFLAGS+=-Wno-error=format-security
5、问题:
如果需要把项目从(mac)Xcode一直到(window)VS2012上面,因为Xcode的默认编码是UTF-8(With BOM),而VS2012对此编码的支持不好,编译时会出现下面的警告:
1>e:\project\trunk\client\project\xxkapai\classes\common\extendclass\ccanimationext.cpp: warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>e:\project\trunk\client\project\xxkapai\classes\common\extendclass\ccanimationext.h: warning C4819: 格式以防止数据丢失
解决:
去掉警告,可以使用转码工具,把文件的编码统一转化为Unicode
6、问题:编译出错
[armeabi] Compile++thumb: cocos_lua_static <= CCLuaBridge.cpp
In file includedfrom E:/project/trunk/client/Project/XXKaPai/Classes/Common/GXC2dxLibrary/GXScrollView/GXMenuItemImage.h:12:0,
fromE:/cocos2d-2.1rc0-x-2.1.3/scripting/lua/proj.android/../cocos2dx_support/CCLuaEngine.h:41,
fromE:/cocos2d-2.1rc0-x-2.1.3/scripting/lua/proj.android/../cocos2dx_support/CCLua Bridge.h:30,
fromE:/cocos2d-2.1rc0-x-2.1.3/scripting/lua/proj.android/../cocos2dx_support/CCLuaBridge.cpp:25:
E:/project/trunk/client/Project/XXKaPai/Classes/Common/GXC2dxLibrary/GXScrollView/GXNode.h:13:24:fatal error: CCMenuItem.h: No such file or directory
compilation terminated.
/cygdrive/e/worksoft/android-ndk-r9d/build/core/build-binary.mk:393:recipe for target 'obj/local/armeabi/objs/cocos_lua_static/__/cocos2dx_support/CCLuaBridge.o' Failed
make: ***[obj/local/armeabi/objs/cocos_lua_static/__/cocos2dx_support/CCLuaBridge.o]Error 1
make: Leavingdirectory '/cygdrive/e/project/trunk/client/Project/XXKaPai/proj.android'
解决:
遇到类似的头文件找不到问题:
1、先查看自己项目android.mk文件是否LOCAL_C_INCLUDES: 变量中,加入了头文件路径。
LOCAL_C_INCLUDES :=$(LOCAL_PATH) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/kazmath/include \
$(LOCAL_PATH)/platform/android
2、查看引入的这个头文件所在工程(路径),看所在工程的android.mk文件是否LOCAL_EXPORT_C_INCLUDES : 变量中,加入了头文件路径。
LOCAL_EXPORT_C_INCLUDES:= $(LOCAL_PATH) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/kazmath/include \
$(LOCAL_PATH)/platform/android\
$(LOCAL_PATH)/menu_nodes
3、如果上面的不能解决问题,在查看,引入的头文件是否使用到,如果没有,则删除,如果有使用到,待解决。。。
问题5:
$ ./build_native.sh
NDK_ROOT =/cygdrive/e/worksoft/android-ndk-r9d
COCOS2DX_ROOT =/cygdrive/e/cocos2d-2.1rc0-x-2.1.3
APP_ROOT = /cygdrive/e/project/trunk/client/Project/XXKaPai/proj.android/..
APP_ANDROID_ROOT =/cygdrive/e/project/trunk/client/Project/XXKaPai/proj.android
Using prebuilt externals
make: Entering directory'/cygdrive/e/project/trunk/client/Project/XXKaPai/proj.android'
Android NDK:WARNING:/cygdrive/e/cocos2d-2.1rc0-x-2.1.3/cocos2dx/Android.mk:cocos2dx_static:LOCAL_LDLIBS is always ignored for static libraries
[armeabi] Compile++ thumb:cocos2dlua_shared <= StringAnd.cpp
jni/../../Classes/Common/platformEx/PtmAndroid/StringAnd.cpp:In static member function 'static char const*StringAnd::getCharacterAtIndex(char const*,int)':
jni/../../Classes/Common/platformEx/PtmAndroid/StringAnd.cpp:60:62:error: no matching function for call to'_JNIEnv::GetStringUTFChars(JNIEnv*&,_jstring*&,bool)'
jni/../../Classes/Common/platformEx/PtmAndroid/StringAnd.cpp:60:62:note: candidate is:
E:/worksoft/android-ndk-r9d/platforms/android-8/arch-arm/usr/include/jni.h:878:17:note: char const* _JNIEnv::GetStringUTFChars(jstring,jboolean*)
E:/worksoft/android-ndk-r9d/platforms/android-8/arch-arm/usr/include/jni.h:878:17:note: candidate expects 2 arguments,3provided
/cygdrive/e/worksoft/android-ndk-r9d/build/core/build-binary.mk:393:recipe for target 'obj/local/armeabi/objs/cocos2dlua_shared/__/__/Classes/Common/platformEx/PtmAndroid/StringAnd.o'Failed
make: ***[obj/local/armeabi/objs/cocos2dlua_shared/__/__/Classes/Common/platformEx/PtmAndroid/StringAnd.o]Error 1
make: Leaving directory'/cygdrive/e/project/trunk/client/Project/XXKaPai/proj.android'
解决:
没有这个方法(三个参数的),只有两个参数的方法,给为两个参数的方法调用即可。
问题6:
使用bluestacks模拟器和eclipse调试android应用,把bluestacks作为默认设备,不需要每次运行应用程序时,选择模拟器,ecplise配置:
问题7:
错误:
10-08 17:24:57.576: D/cocos2d-x debuginfo(9820): on update finish!
10-08 17:24:57.626: D/cocos2d-x debuginfo(9820): value at stack [-1] is not function
原文链接:https://www.f2er.com/cocos2dx/344802.html