cocos2d-x 3.17 编译不过

cocos2d-x 使用了 cocos new -p com.fly.test -l lua 创建了工程,到工程目录下执行编译命令如下
cocos compile -p android -m release

编译日志
Successfully started process ‘command ‘D:\work\dev_env\android-ndk-r16b\ndk-build.cmd’’
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_audioengine_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= CCComponentLua.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_3d_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_cocosdenshion_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_cocosbuilder_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_csloader_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_studio_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua-cocos-studio-conversions.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_spine_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_experimental_video_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_ui_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_experimental_webview_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_extension_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_physics3d_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_navmesh_auto.cpp
In file included from
D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/scripting/lua-bindings/proj.android/…/auto/lua_cocos2dx_physics3d_auto.cp
p:3:
In file included from D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/3d/…\physics3d/CCPhysics3D.h:55:
In file included from D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/scripting/lua-bindings/proj.android/…/…/…/…/exte
rnal/bullet/prebuilt/android/…/…/include\bullet/btBulletCollisionCommon.h:35:
In file included from D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/…/external/bullet/include/bullet/BulletCollision/Co
llisionShapes/btBvhTriangleMeshShape.h:22:
In file included from D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/…/external/bullet/include/bullet/BulletCollision/Co
llisionShapes/btTriangleInfoMap.h:20:
D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/…/external/bullet/include/bullet\LinearMath/btHashMap.h
:20:10: fatal error: ‘btAlignedObjectArray.h’ file not found
#include “btAlignedObjectArray.h”
^~~~~~~~~~~~~~~~~~~~~~~~
1
error generated.
make: *** [D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/cocos2d_lua_static/__/auto/lua_
cocos2dx_physics3d_auto.o] Error 1
make: *** Waiting for unfinished jobs…

:MyLuaGame:externalNativeBuildRelease (Thread[Task worker for ‘:’ Thread 2,5,main]) completed. Took 17.046 secs.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:MyLuaGame:externalNativeBuildRelease’.

Build command failed.
Error while executing process D:\work\dev_env\android-ndk-r16b\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\work\code\upgraded_proj\test\MyLuaGame\frameworks\r
untime-src\proj.android\app\jni\Android.mk NDK_APPLICATION_MK=D:\work\code\upgraded_proj\test\MyLuaGame\frameworks\runtime-src\proj.android\app\jni\Application.mk APP_ABI=armeabi-v7a NDK_A
LL_ABIS=armeabi-v7a NDK_DEBUG=0 APP_PLATFORM=android-14 NDK_OUT=D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/release/obj N
DK_LIBS_OUT=D:\work\code\upgraded_proj\test\MyLuaGame\frameworks\runtime-src\proj.android\app\build\intermediates\ndkBuild\release\lib NDK_TOOLCHAIN_VERSION=clang -j4 NDK_DEBUG=0 D:/work/c
ode/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/libcocos2dlua.so}
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_audioengine_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= CCComponentLua.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_3d_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_cocosdenshion_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_cocosbuilder_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_csloader_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_studio_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua-cocos-studio-conversions.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_spine_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_experimental_video_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_ui_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_experimental_webview_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_extension_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_physics3d_auto.cpp
[armeabi-v7a] Compile++ arm : cocos2d_lua_static <= lua_cocos2dx_navmesh_auto.cpp
In file included from D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/scripting/lua-bindings/proj.android/…/auto/lua_co
cos2dx_physics3d_auto.cpp:3:
In file included from D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/3d/…\physics3d/CCPhysics3D.h:55:
In file included from D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/scripting/lua-bindings/proj.android/…/…/…/…/ex
ternal/bullet/prebuilt/android/…/…/include\bullet/btBulletCollisionCommon.h:35:
In file included from D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/…/external/bullet/include/bullet/BulletCollision/
CollisionShapes/btBvhTriangleMeshShape.h:22:
In file included from D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/…/external/bullet/include/bullet/BulletCollision/
CollisionShapes/btTriangleInfoMap.h:20:
D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/jni/…/…/…/…/cocos2d-x/cocos/…/external/bullet/include/bullet\LinearMath/btHashMap.h:20:10: fatal er
ror: ‘btAlignedObjectArray.h’ file not found
#include “btAlignedObjectArray.h”
^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [D:/work/code/upgraded_proj/test/MyLuaGame/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/cocos2d_lua_static/__/auto/lu
a_cocos2dx_physics3d_auto.o] Error 1
make: *** Waiting for unfinished jobs…

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 52s
51 actionable tasks: 51 executed
执行命令出错,返回值:1。

用android studio打开之后 直接debug也是包同样的错误

遇到同样的问题 求解答

如果我没有猜错,你的问题跟我之前一样的,在cocos3.17版的需要VS2015以上才能支持(包括2015)。

已经解决 找不到头文件 需要在Android.mk文件中添加搜索路径

你添加了搜索路径?能贴出来我看看吗?我一直怀疑是路径过长导致的,你把编译通过了,我参考看看,多一个解决方案,谢谢!

找不到这个头文件 我添加了绿色部分的搜索路径 cocos下面的 Android.mk

另外 上面的问题解决后 官网说r16 NDK 可以编译过 但是我用了后编译不过 问题比较多 换成r18 就可以了

1赞

可以确定了,windows上如果路径超过255之后,ndk识别不了文件。把项目路径放浅一点就好了。