【问题概述】 使用官方的2D demo, hello world 直接导出后使用android studio编译, 无法成功编译。
-
Creator 版本: 3.8.1
-
目标平台: Android
-
重现方式: 直接使用官方demo,如图配置,进行编译。
-
首个报错:
> Task :helloworld2:buildCMakeRelWithDebInfo[x86][cocos] FAILED
C/C++: ninja: Entering directory `/Users/chendongsheng/helloworld/build/android/proj/build/RelWithDebInfo/3jtl8681/x86'
C/C++: [1/1] Linking CXX shared library /Users/chendongsheng/helloworld/build/android/proj/build/helloworld2/intermediates/cxx/RelWithDebInfo/3jtl8681/obj/x86/libcocos.so
C/C++: FAILED: /Users/chendongsheng/helloworld/build/android/proj/build/helloworld2/intermediates/cxx/RelWithDebInfo/3jtl8681/obj/x86/libcocos.so
C/C++: : && /Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=i686-none-linux-android21 --sysroot=/Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -ffunction-sections -fdata-sections -fstrict-aliasing -frtti -fexceptions -fvisibility=hidden -fvisibility-inlines-hidden -O2 -g -DNDEBUG -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -u GameActivity_onCreate -Wl,--gc-sections -Wl,--gc-sections -shared -Wl,-soname,libcocos.so -o /Users/chendongsheng/helloworld/build/android/proj/build/helloworld2/intermediates/cxx/RelWithDebInfo/3jtl8681/obj/x86/libcocos.so CMakeFiles/cocos.dir/Users/chendongsheng/helloworld/native/engine/common/Classes/Game.cpp.o -Wl,--whole-archive libcocos_jni.a -Wl,--no-whole-archive libcocos_engine.a -llog libandroid_platform.a -landroid libpaddleboat_static.a -lOpenSLES /Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/i686-linux-android/21/libEGL.so -ljnigraphics boost/container/libboost_container.a libpvmp3dec.a libvorbisidec.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/v8/libinspector.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libjpeg.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libpng.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libwebp.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libz.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/v8/libv8_monolith.a -latomic -lm && :
C/C++: ld.lld: error: undefined hidden symbol: __stack_chk_fail_local
C/C++: >>> referenced by async.o:(uv__async_io) in archive /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a
C/C++: >>> referenced by async.o:(uv__async_start.part.0) in archive /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a
C/C++: >>> referenced by android-ifaddrs.o:(getResultList) in archive /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a
C/C++: >>> referenced 26 more times
C/C++: clang++: error: linker command failed with exit code 1 (use -v to see invocation)
C/C++: ninja: build stopped: subcommand failed.
: && /Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=i686-none-linux-android21 --sysroot=/Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -ffunction-sections -fdata-sections -fstrict-aliasing -frtti -fexceptions -fvisibility=hidden -fvisibility-inlines-hidden -O2 -g -DNDEBUG -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -u GameActivity_onCreate -Wl,--gc-sections -Wl,--gc-sections -shared -Wl,-soname,libcocos.so -o /Users/chendongsheng/helloworld/build/android/proj/build/helloworld2/intermediates/cxx/RelWithDebInfo/3jtl8681/obj/x86/libcocos.so CMakeFiles/cocos.dir/Users/chendongsheng/helloworld/native/engine/common/Classes/Game.cpp.o -Wl,--whole-archive libcocos_jni.a -Wl,--no-whole-archive libcocos_engine.a -llog libandroid_platform.a -landroid libpaddleboat_static.a -lOpenSLES /Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/i686-linux-android/21/libEGL.so -ljnigraphics boost/container/libboost_container.a libpvmp3dec.a libvorbisidec.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/v8/libinspector.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libjpeg.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libpng.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libwebp.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libz.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/v8/libv8_monolith.a -latomic -lm && :
ld.lld: error: undefined hidden symbol: __stack_chk_fail_local
>>> referenced by async.o:(uv__async_io) in archive /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a
>>> referenced by async.o:(uv__async_start.part.0) in archive /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a
>>> referenced by android-ifaddrs.o:(getResultList) in archive /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a
>>> referenced 26 more times
: && /Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=i686-none-linux-android21 --sysroot=/Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -ffunction-sections -fdata-sections -fstrict-aliasing -frtti -fexceptions -fvisibility=hidden -fvisibility-inlines-hidden -O2 -g -DNDEBUG -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -u GameActivity_onCreate -Wl,--gc-sections -Wl,--gc-sections -shared -Wl,-soname,libcocos.so -o /Users/chendongsheng/helloworld/build/android/proj/build/helloworld2/intermediates/cxx/RelWithDebInfo/3jtl8681/obj/x86/libcocos.so CMakeFiles/cocos.dir/Users/chendongsheng/helloworld/native/engine/common/Classes/Game.cpp.o -Wl,--whole-archive libcocos_jni.a -Wl,--no-whole-archive libcocos_engine.a -llog libandroid_platform.a -landroid libpaddleboat_static.a -lOpenSLES /Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/i686-linux-android/21/libEGL.so -ljnigraphics boost/container/libboost_container.a libpvmp3dec.a libvorbisidec.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/v8/libinspector.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libjpeg.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libpng.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libwebp.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libz.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/v8/libv8_monolith.a -latomic -lm && :
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Execution failed for task ':helloworld2:buildCMakeRelWithDebInfo[x86][cocos]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/Users/chendongsheng/helloworld/build/android/proj/build/RelWithDebInfo/3jtl8681/x86'
[1/1] Linking CXX shared library /Users/chendongsheng/helloworld/build/android/proj/build/helloworld2/intermediates/cxx/RelWithDebInfo/3jtl8681/obj/x86/libcocos.so
FAILED: /Users/chendongsheng/helloworld/build/android/proj/build/helloworld2/intermediates/cxx/RelWithDebInfo/3jtl8681/obj/x86/libcocos.so
: && /Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=i686-none-linux-android21 --sysroot=/Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -ffunction-sections -fdata-sections -fstrict-aliasing -frtti -fexceptions -fvisibility=hidden -fvisibility-inlines-hidden -O2 -g -DNDEBUG -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -u GameActivity_onCreate -Wl,--gc-sections -Wl,--gc-sections -shared -Wl,-soname,libcocos.so -o /Users/chendongsheng/helloworld/build/android/proj/build/helloworld2/intermediates/cxx/RelWithDebInfo/3jtl8681/obj/x86/libcocos.so CMakeFiles/cocos.dir/Users/chendongsheng/helloworld/native/engine/common/Classes/Game.cpp.o -Wl,--whole-archive libcocos_jni.a -Wl,--no-whole-archive libcocos_engine.a -llog libandroid_platform.a -landroid libpaddleboat_static.a -lOpenSLES /Users/chendongsheng/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/i686-linux-android/21/libEGL.so -ljnigraphics boost/container/libboost_container.a libpvmp3dec.a libvorbisidec.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/v8/libinspector.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libjpeg.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libpng.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libwebp.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libz.a /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/v8/libv8_monolith.a -latomic -lm && :
ld.lld: error: undefined hidden symbol: __stack_chk_fail_local
>>> referenced by async.o:(uv__async_io) in archive /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a
>>> referenced by async.o:(uv__async_start.part.0) in archive /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a
>>> referenced by android-ifaddrs.o:(getResultList) in archive /Applications/Cocos/Creator/3.8.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/external/cmake/../android/x86/libuv.a
>>> referenced 26 more times
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 --info or --debug option to get more log output.
> Run with --scan to get full insights.
- 编辑器操作系统: MACOS
- 重现概率: 100%
- 原始项目
- 编译截图
- cocos编译导出选项
- 个人NDK & SDK版本
- android studio版本
Android Studio Giraffe | 2022.3.1 Patch 2
Build #AI-223.8836.35.2231.10811636, built on September 15, 2023
Runtime version: 17.0.6+0-17.0.6b829.9-10027231 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16
Metal Rendering is ON
Registry:
external.system.auto.import.disabled=true
ide.text.editor.with.preview.show.floating.toolbar=false






