Cocos 4.0新建lua项目安卓打包报错,CCLuaEngine,lua51.lib

使用cocos compile -p android编译安卓包,编译CCLuaEngine.cpp时报错

ld: error: lib/libluacocos2d.a(CCLuaEngine.cpp.o): unable to find library from dependent library specifier: lua51.lib

应该是 #pragma comment(lib,“lua51.lib”) 这句代码报错,找不到lua51.lib

有同学提供一下解决思路嘛?

以下是报错前后相关信息

[801/804] Linking CXX static library engine\cocos\platform\libcpp_android_spec.a
[802/804] Building CXX object engine/cocos/lua-bindings/CMakeFiles/luacocos2d.dir/auto/lua_cocos2dx_auto.cpp.o
[803/804] Linking CXX static library lib\libluacocos2d.a
[804/804] Linking CXX shared library bin\cocos2dlua\libcocos2dlua.so
FAILED: bin/cocos2dlua/libcocos2dlua.so
cmd.exe /C “cd . && G:\Android\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=i686-none-linux-android24 --gcc-toolchain=G:/Android/android-ndk-r22/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=G:/Android/android-ndk-r22/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -frtti -fexceptions -fsigned-char -O2 -DNDEBUG -Wl,–exclude-libs,libgcc.a -Wl,–exclude-libs,libgcc_real.a -Wl,–exclude-libs,libatomic.a -static-libstdc++ -Wl,–build-id=sha1 -Wl,–no-rosegment -Wl,–fatal-warnings -Wl,–no-undefined -Qunused-arguments -shared -Wl,-soname,libcocos2dlua.so -o bin\cocos2dlua\libcocos2dlua.so CMakeFiles/cocos2dlua.dir/frameworks/runtime-src/Classes/AppDelegate.cpp.o CMakeFiles/cocos2dlua.dir/frameworks/runtime-src/Classes/network/Network.cpp.o CMakeFiles/cocos2dlua.dir/frameworks/runtime-src/Classes/network/GameSocket.cpp.o CMakeFiles/cocos2dlua.dir/frameworks/runtime-src/Classes/utility/GameHelper.cpp.o CMakeFiles/cocos2dlua.dir/frameworks/runtime-src/Classes/utility/Md5.cpp.o CMakeFiles/cocos2dlua.dir/frameworks/runtime-src/Classes/lua_GameHelper_auto.cpp.o CMakeFiles/cocos2dlua.dir/frameworks/runtime-src/Classes/lua_network.cpp.o CMakeFiles/cocos2dlua.dir/frameworks/runtime-src/proj.android/app/jni/hellolua/main.cpp.o -Wl,–whole-archive engine/cocos/platform/libcpp_android_spec.a -Wl,–no-whole-archive -Wl,–whole-archive engine/cocos/lua-android/liblua_android_spec.a -Wl,–no-whole-archive lib/libluacocos2d.a lib/libcocos2d.a lib/libexternal.a …/…/…/…/…/…/…/cocos2d-x/external/Box2D/prebuilt/android/x86/libbox2d.a …/…/…/…/…/…/…/cocos2d-x/external/chipmunk/prebuilt/android/x86/libchipmunk.a …/…/…/…/…/…/…/cocos2d-x/external/freetype2/prebuilt/android/x86/libfreetype.a lib/libext_recast.a …/…/…/…/…/…/…/cocos2d-x/external/bullet/prebuilt/android/x86/libLinearMath.a …/…/…/…/…/…/…/cocos2d-x/external/bullet/prebuilt/android/x86/libBulletDynamics.a …/…/…/…/…/…/…/cocos2d-x/external/bullet/prebuilt/android/x86/libBulletCollision.a …/…/…/…/…/…/…/cocos2d-x/external/bullet/prebuilt/android/x86/libLinearMath.a …/…/…/…/…/…/…/cocos2d-x/external/bullet/prebuilt/android/x86/libBulletMultiThreaded.a …/…/…/…/…/…/…/cocos2d-x/external/bullet/prebuilt/android/x86/libMiniCL.a …/…/…/…/…/…/…/cocos2d-x/external/jpeg/prebuilt/android/x86/libjpeg.a …/…/…/…/…/…/…/cocos2d-x/external/webp/prebuilt/android/x86/libwebp.a …/…/…/…/…/…/…/cocos2d-x/external/websockets/prebuilt/android/x86/libwebsockets.a …/…/…/…/…/…/…/cocos2d-x/external/openssl/prebuilt/android/x86/libssl.a …/…/…/…/…/…/…/cocos2d-x/external/openssl/prebuilt/android/x86/libcrypto.a …/…/…/…/…/…/…/cocos2d-x/external/uv/prebuilt/android/x86/libuv_a.a lib/libext_tinyxml2.a lib/libext_xxhash.a lib/libext_xxtea.a lib/libext_clipper.a lib/libext_edtaa3func.a lib/libext_convertUTF.a lib/libext_poly2tri.a lib/libext_md5.a …/…/…/…/…/…/…/cocos2d-x/external/curl/prebuilt/android/x86/libcurl.a …/…/…/…/…/…/…/cocos2d-x/external/png/prebuilt/android/x86/libpng.a engine/external/android-specific/cpufeatures/libext_cpufeatures.a -ldl lib/libext_pvmp3dec.a lib/libext_tremolo.a …/…/…/…/…/…/…/cocos2d-x/external/zlib/prebuilt/android/x86/libz.a lib/libext_unzip.a -lGLESv2 -lEGL -llog -landroid -lOpenSLES …/…/…/…/…/…/…/cocos2d-x/external/lua/luajit/prebuilt/android/x86/libluajit.a lib/libext_tolua.a lib/libext_luasocket.a -latomic -lm && cd .”
ld: error: lib/libluacocos2d.a(CCLuaEngine.cpp.o): unable to find library from dependent library specifier: lua51.lib
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

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

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

BUILD FAILED in 2m 33s
50 actionable tasks: 2 executed, 48 up-to-date
执行命令出错,返回值:1。

这样编译就过了

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#pragma comment(lib,“lua51.lib”)
#endif

应该没啥问题吧

能运行 但是黑屏了

看看什么报错呢

黑屏原因是里面没有文件 哈哈 build-cfg.json 里面的copy_resources可能是空的