Tencent / puerts

PUER(普洱) Typescript. Let's write your game in UE or Unity with TypeScript.
Other
5.07k stars 707 forks source link

[Unity] (2021lts 多个版本都出现)il2cpp遇到一个非常诡异的问题,可能是unity的bug #1369

Closed mingxxming closed 1 year ago

mingxxming commented 1 year ago

C:\Projects\rgd\game\u3d\release\2023_6_2\GC_OHAYOO_MOCK_16_08.apk\unityLibrary\src\main\Il2CppOutputProject\IL2CPP\build\deploy\il2cpp.exe --compile-cpp --platform=Android --architecture=arm64 --outputpath=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/jniLibs/arm64-v8a/libil2cpp.so --libil2cpp-static --baselib-directory=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/jniStaticLibs/arm64-v8a --incremental-g-c-time-slice=3 --configuration=Release --dotnetprofile=unityaot-linux --profiler-report --profiler-output-file=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/build/il2cpp_arm64-v8a_Release/il2cpp_conv.traceevents --print-command-line --generatedcppdir=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput --cachedirectory=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/build/il2cpp_arm64-v8a_Release/il2cpp_cache --tool-chain-path=C:\Users\monster\AppData\Local\Android\Sdk\ndk\21.3.6528147 --additional-libraries=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/jniStaticLibs/arm64-v8a/libpuerts_il2cpp.a --additional-libraries=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/jniStaticLibs/arm64-v8a/libwee8.a 以上是il2cpp成功出android包的情况

C:\Projects\rgd\game\u3d\release\2023_6_2\GC_OHAYOO_MOCK_16_08.apk\unityLibrary\src\main\Il2CppOutputProject\IL2CPP\build\deploy\il2cpp.exe --compile-cpp --platform=Android --architecture=arm64 --outputpath=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/jniLibs/arm64-v8a/libil2cpp.so --libil2cpp-static --baselib-directory=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/jniStaticLibs/arm64-v8a --incremental-g-c-time-slice=3 --configuration=Release --dotnetprofile=unityaot-linux --profiler-report --profiler-output-file=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/build/il2cpp_arm64-v8a_Release/il2cpp_conv.traceevents --print-command-line --generatedcppdir=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput --cachedirectory=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/build/il2cpp_arm64-v8a_Release/il2cpp_cache --tool-chain-path=C:\Users\monster\AppData\Local\Android\Sdk\ndk\21.3.6528147 --additional-libraries=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/jniStaticLibs/arm64-v8a/libwee8.a --additional-libraries=C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_16_08.apk/unityLibrary/src/main/jniStaticLibs/arm64-v8a/libpuerts_il2cpp.a 以上是il2cpp出android包,在link阶段出现v8 的所有引用不存在的情况,如: C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_17_51.apk/unityLibrary/src/main/jniStaticLibs/arm64-v8a/libpuerts_il2cpp.a(Puerts.cpp.o): In function puerts::w_i4ti4o(void*, void (*)(), v8::FunctionCallbackInfo<v8::Value> const&, bool, puerts::WrapData*)': /home/runner/work/puerts/puerts/unity/native_src_il2cpp/Src/FunctionBridge.Gen.h:7840: undefined reference tov8::Value::IsObject() const' /home/runner/work/puerts/puerts/unity/native_src_il2cpp/Src/FunctionBridge.Gen.h:7840: undefined reference to v8::Value::IsObject() const' /home/runner/work/puerts/puerts/unity/native_src_il2cpp/Src/FunctionBridge.Gen.h:7840: undefined reference tov8::Value::IsFunction() const' /home/runner/work/puerts/puerts/unity/native_src_il2cpp/Src/FunctionBridge.Gen.h:7840: undefined reference to `v8::Value::IsFunction() const' C:/Projects/rgd/game/u3d/release/2023_6_2/GC_OHAYOO_MOCK_17_51.apk/unityLibrary/src/main/jniStaticLibs/arm64-v8a/libpuerts_il2cpp.a(Puerts.cpp.o

在AS中手动 调整俩库位置后编译成功。

zombieyang commented 1 year ago

调整两个库的位置 是指哪两个?

mingxxming commented 1 year ago

--additional-libraries=libpuerts_il2cpp.a --additional-libraries=libwee8.a ok --additional-libraries=libwee8.a --additional-libraries=libpuerts_il2cpp.a fail

chexiongsheng commented 1 year ago

可以试试合并这两个库看能否解决问题。 libwee8.a和libpuerts_il2cpp.a合并成一个.a静态库。

chexiongsheng commented 1 year ago

用ndk的ar命令,如果能解决问题,后续修改CMakeList自动做这个合并操作。

mingxxming commented 1 year ago

ar -x libpuerts_il2cpp.a ar -rs libwee8.a *.o mv libwee8.a xxx/libpuerts_il2cpp.a 这个ok

zombieyang commented 1 year ago

要用NDK里的ar

而且将libwee8 x出来重新打.a之后,无论如何它内部的依赖都会丢。唯一能通的情况似乎是 ar x libpuerts_il2cpp.a,然后 ar q libwee8.a *.o。即把puerts拆开来append到wee8里去,然后把libwee8.a丢进Unity。

有空再查查原因

mingxxming commented 1 year ago

不需要用ndk的 ar 不涉及编译,上面的测试是ok的。之前闪退是因为https://github.com/Tencent/puerts/issues/1376

chexiongsheng commented 1 year ago

要用NDK里的ar

而且将libwee8 x出来重新打.a之后,无论如何它内部的依赖都会丢。唯一能通的情况似乎是 ar x libpuerts_il2cpp.a,然后 ar q libwee8.a *.o。即把puerts拆开来append到wee8里去,然后把libwee8.a丢进Unity。

有空再查查原因

我说的就是你能通的做法,这做法本质就是两个.a合并成一个。并不是把libwee8拆开然后重新打包。

zombieyang commented 1 year ago

要用NDK里的ar 而且将libwee8 x出来重新打.a之后,无论如何它内部的依赖都会丢。唯一能通的情况似乎是 ar x libpuerts_il2cpp.a,然后 ar q libwee8.a *.o。即把puerts拆开来append到wee8里去,然后把libwee8.a丢进Unity。 有空再查查原因

我说的就是你能通的做法,这做法本质就是两个.a合并成一个。并不是把libwee8拆开然后重新打包。

我回复的是 @mingxxming 之前的评论,他的评论早上编辑过