gpt4 book ai didi

android - Unity Android Build 在 Mono 中工作,但由于 undefined reference 、缺少库而在 IL2CPP 中失败

转载 作者:行者123 更新时间:2023-12-04 23:49:12 27 4
gpt4 key购买 nike

我正在尝试更新我们在 Google Play 商店中已存在多年的基于 ARToolkit5 的 Unity Android 应用程序。 ARToolkit5 不再受支持,但我们仍然依赖于大约 4 年前构建的库。我的 Unity 版本是 2020.1.11f1。
我需要将应用升级到 Google App Bundle 并添加 64 位支持。所以第一步,我理解,是从 Mono 改为 IL2CPP 作为 Scripting Backend。 32 位 Android ARMv7 应用程序在 Mono 中构建并且运行良好,但是当我实际上只进行一项更改时,即在项目设置下切换到 IL2CPP 作为脚本后端时,构建失败。我什至还没有尝试添加 ARM64 选项。
使用 IL2CPP 时,构建失败并显示 BuilderFailedException和数百个 Undefined References ...

Exception: /Applications/2020.1.11f1/Unity.app/Contents/il2cpp/build/deploy/net471/il2cpp.exe did not run properly!

Failed running "/Applications/2020.1.11f1/Unity.app/Contents/il2cpp/build/deploy/net471/il2cpp.exe" --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="<redacted>/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a/libil2cpp.so" --cachedirectory="<redacted>/Assets/../Library/il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="/Applications/2020.1.11f1/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" --additional-include-directories="/Applications/2020.1.11f1/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" --baselib-directory="/Applications/2020.1.11f1/PlaybackEngines/AndroidPlayer/Variations/il2cpp/Release/StaticLibs/armeabi-v7a" --avoid-dynamic-library-copy --tool-chain-path="/Applications/2020.1.11f1/PlaybackEngines/AndroidPlayer/NDK" --profiler-report --map-file-parser="/Applications/2020.1.11f1/Unity.app/Contents/Tools/MapFileParser/MapFileParser" --directory="<redacted>/Temp/StagingArea/assets/bin/Data/Managed" --generatedcppdir="<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput"

stdout:
Running il2cpp.exe in workstation GC mode.
Building libil2cpp.so with AndroidToolChain
Output directory: <redacted>/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a
Cache directory: <redacted>/Library/il2cpp_android_armeabi-v7a/il2cpp_cache
ObjectFiles: 186 of which compiled: 0
Total compilation time: 157 milliseconds.
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: /Applications/2020.1.11f1/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ @"/var/folders/vc/9b7436817vzgvxlqrftcl1nr0000gn/T/tmp1b926095.tmp" -o "<redacted>/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/linkresult_01F24D8C43A06CD45FA9C75071D0A3D6/libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id -stdlib=libc++ -static-libstdc++ -target armv7-linux-androideabi19 -Wl,--wrap,sigaction "/Applications/2020.1.11f1/PlaybackEngines/AndroidPlayer/Variations/il2cpp/Release/StaticLibs/armeabi-v7a/baselib.a" -llog -rdynamic -fuse-ld=gold

<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28131: error: undefined reference to 'arwRegisterLogCallback'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28140: error: undefined reference to 'arwSetLogLevel'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28149: error: undefined reference to 'arwInitialiseAR'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28159: error: undefined reference to 'arwInitialiseARWithOptions'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28173: error: undefined reference to 'arwGetARToolKitVersion'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28190: error: undefined reference to 'arwGetError'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28200: error: undefined reference to 'arwShutdownAR'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28221: error: undefined reference to 'arwStartRunningB'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28235: error: undefined reference to 'arwIsRunning'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28245: error: undefined reference to 'arwStopRunning'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28262: error: undefined reference to 'arwGetProjectionMatrix'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28276: error: undefined reference to 'arwGetVideoParams'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28293: error: undefined reference to 'arwCapture'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28303: error: undefined reference to 'arwUpdateAR'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28313: error: undefined reference to 'arwUpdateTexture32'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28323: error: undefined reference to 'arwGetMarkerPatternCount'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28340: error: undefined reference to 'arwGetMarkerPatternConfig'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28357: error: undefined reference to 'arwGetMarkerPatternImage'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28367: error: undefined reference to 'arwGetMarkerOptionBool'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28377: error: undefined reference to 'arwSetMarkerOptionBool'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28386: error: undefined reference to 'arwGetMarkerOptionInt'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28396: error: undefined reference to 'arwSetMarkerOptionInt'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28405: error: undefined reference to 'arwGetMarkerOptionFloat'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28415: error: undefined reference to 'arwSetMarkerOptionFloat'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28424: error: undefined reference to 'arwSetVideoDebugMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28433: error: undefined reference to 'arwGetVideoDebugMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28443: error: undefined reference to 'arwSetVideoThreshold'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28452: error: undefined reference to 'arwGetVideoThreshold'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28462: error: undefined reference to 'arwSetVideoThresholdMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28471: error: undefined reference to 'arwGetVideoThresholdMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28481: error: undefined reference to 'arwSetLabelingMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28490: error: undefined reference to 'arwGetLabelingMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28500: error: undefined reference to 'arwSetBorderSize'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28509: error: undefined reference to 'arwGetBorderSize'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28519: error: undefined reference to 'arwSetPatternDetectionMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28528: error: undefined reference to 'arwGetPatternDetectionMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28538: error: undefined reference to 'arwSetMatrixCodeType'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28547: error: undefined reference to 'arwGetMatrixCodeType'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28557: error: undefined reference to 'arwSetImageProcMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28566: error: undefined reference to 'arwGetImageProcMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28576: error: undefined reference to 'arwSetNFTMultiMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28585: error: undefined reference to 'arwGetNFTMultiMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28599: error: undefined reference to 'arwAddMarker'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28613: error: undefined reference to 'arwRemoveMarker'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28623: error: undefined reference to 'arwRemoveAllMarkers'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28633: error: undefined reference to 'arwQueryMarkerVisibility'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28650: error: undefined reference to 'arwQueryMarkerTransformation'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28685: error: undefined reference to 'arwLoadOpticalParams'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)


at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles (System.Collections.Generic.HashSet`1[T] objectFiles, Unity.IL2CPP.Building.ToolChains.CppToolChainContext toolChainContext) [0x00203] in <bb3d372ae2c942d1b47f060d5cd89a4d>:0
at Unity.IL2CPP.Building.CppProgramBuilder.Build (Unity.IL2CPP.Building.Statistics.IBuildStatistics& statistics) [0x0025c] in <bb3d372ae2c942d1b47f060d5cd89a4d>:0
at Unity.IL2CPP.Building.Statistics.BuildingTestRunnerHelper.BuildAndLogStatsForTestRunner (Unity.IL2CPP.Building.CppProgramBuilder builder, Unity.IL2CPP.Building.Statistics.IBuildStatistics& statistics) [0x00000] in <bb3d372ae2c942d1b47f060d5cd89a4d>:0
at il2cpp.Compilation.CompilationDriver.Run (Unity.IL2CPP.Common.RuntimePlatform platform, Unity.IL2CPP.Building.BuildingOptions buildingOptions) [0x001fd] in <3be9f628f5fa469389bd6a91a579ba8a>:0
at il2cpp.Program.DoRun (System.String[] args, Unity.IL2CPP.Common.RuntimePlatform platform, Unity.IL2CPP.Building.BuildingOptions buildingOptions) [0x0001f] in <3be9f628f5fa469389bd6a91a579ba8a>:0
at il2cpp.Program.Run (System.String[] args, System.Boolean setInvariantCulture) [0x00063] in <3be9f628f5fa469389bd6a91a579ba8a>:0
at il2cpp.Program.Main (System.String[] args) [0x00000] in <3be9f628f5fa469389bd6a91a579ba8a>:0
stderr:

Unhandled Exception:
Unity.IL2CPP.Building.BuilderFailedException: /Applications/2020.1.11f1/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ @"/var/folders/vc/9b7436817vzgvxlqrftcl1nr0000gn/T/tmp1b926095.tmp" -o "<redacted>/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/linkresult_01F24D8C43A06CD45FA9C75071D0A3D6/libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id -stdlib=libc++ -static-libstdc++ -target armv7-linux-androideabi19 -Wl,--wrap,sigaction "/Applications/2020.1.11f1/PlaybackEngines/AndroidPlayer/Variations/il2cpp/Release/StaticLibs/armeabi-v7a/baselib.a" -llog -rdynamic -fuse-ld=gold

<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28131: error: undefined reference to 'arwRegisterLogCallback'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28140: error: undefined reference to 'arwSetLogLevel'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28149: error: undefined reference to 'arwInitialiseAR'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28159: error: undefined reference to 'arwInitialiseARWithOptions'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28173: error: undefined reference to 'arwGetARToolKitVersion'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28190: error: undefined reference to 'arwGetError'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28200: error: undefined reference to 'arwShutdownAR'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28221: error: undefined reference to 'arwStartRunningB'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28235: error: undefined reference to 'arwIsRunning'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28245: error: undefined reference to 'arwStopRunning'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28262: error: undefined reference to 'arwGetProjectionMatrix'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28276: error: undefined reference to 'arwGetVideoParams'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28293: error: undefined reference to 'arwCapture'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28303: error: undefined reference to 'arwUpdateAR'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28313: error: undefined reference to 'arwUpdateTexture32'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28323: error: undefined reference to 'arwGetMarkerPatternCount'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28340: error: undefined reference to 'arwGetMarkerPatternConfig'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28357: error: undefined reference to 'arwGetMarkerPatternImage'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28367: error: undefined reference to 'arwGetMarkerOptionBool'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28377: error: undefined reference to 'arwSetMarkerOptionBool'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28386: error: undefined reference to 'arwGetMarkerOptionInt'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28396: error: undefined reference to 'arwSetMarkerOptionInt'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28405: error: undefined reference to 'arwGetMarkerOptionFloat'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28415: error: undefined reference to 'arwSetMarkerOptionFloat'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28424: error: undefined reference to 'arwSetVideoDebugMode'
<redacted>/Temp/StagingArea/Il2Cpp/il2cppOutput/Assembly-CSharp.cpp:28433: error: undefined referen<message truncated>
我认为这说明链接器找不到列出的函数的定义,所有这些都来自一个 ARToolkit 库: libARWrapper.so此库存在于 Unity 项目中: Assets/Plugins/Android/lib/armeabi-v7a/libARWrapper.so .
在 Unity Inspector 中快速检查显示库导入设置似乎是正确的。
Unity Inspector: libARWrapper.so Import Settings
这似乎表明这个库将包含在 Android ARMv7 版本中,就是这样。而且我知道该库可以在 ARMv7 设备上运行和运行,并且使用 Mono 构建,所以我认为它只是以某种方式被排除在 IL2CPP 构建之外。
所以总而言之,Mono 在其构建中包含 libARWrapper.so 库,但是当我为完全相同的项目切换到 IL2CPP 时,该库不包含在内,因此无法链接。
有谁知道为什么会这样?谢谢!

最佳答案

插件中的代码tries to P/Invoke into these APIs by declaring that they're in the same binary as your C# code :

    [DllImport("__Internal")]
public static extern void arwRegisterLogCallback(PluginFunctions.LogCallback callback);

[DllImport("__Internal")]
public static extern void arwSetLogLevel(int logLevel);

[DllImport("__Internal")]
[return: MarshalAsAttribute(UnmanagedType.I1)]
public static extern bool arwInitialiseAR();
"__Internal"是一个特殊的 DLL 名称,它告诉 IL2CPP 直接向这些 API 发出调用,并相信链接器能够解析它们。但是,这些 API 实际上存在于 libARWrapper.so 中。 (而不是在 Unity 项目中松散的 .cpp 文件中),因此链接器无法找到它们。更改 [DllImport("__Internal")] 的所有实例至 [DllImport("libARWrapper.so")]将解决您的问题。

关于android - Unity Android Build 在 Mono 中工作,但由于 undefined reference 、缺少库而在 IL2CPP 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65853741/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com