xll2cpp编译记录

随笔7个月前发布 锦锦在悉尼
88 0 0

VMware 安装 centOS 8

https://mirrors.aliyun.com/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-latest-dvd1.iso
https://blog.51cto.com/u_16596714/10118179
注意,swap分区不能像上述教程中设置2G,这样会出现后面build的时候的input/output错误,直接设置20G

安装nodejs 20

https://zhuanlan.zhihu.com/p/672114690

安装cmake

https://blog.csdn.net/muxuen/article/details/132591664

WMware设置共享文件夹并挂在puerts项目和ndk

https://blog.csdn.net/qq_34484062/article/details/116503084

[root@localhost hgfs]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue May  7 12:10:13 2024
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=f416eb3b-3309-42d2-a221-a99fb0d31e26 /                       xfs     defaults        0 0
UUID=1428cbef-4afa-4c9b-b345-2765e900223c /boot                   ext4    defaults        1 2
UUID=4e04735f-4409-4523-bee0-6978fc2af0e1 none                    swap    defaults        0 0
.host:/puerts /mnt/hgfs/puerts fuse.vmhgfs-fuse allow_other,defaults 0 0
.host:/ndk-linux /mnt/hgfs/ndk fuse.vmhgfs-fuse allow_other,defaults 0 0

添加ANDROID_NDK环境变量

vim ~/.bashrc添加环境变量,source ~/.bashrc使之生效

[root@localhost hgfs]# cat ~/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

export ANDROID_NDK=/mnt/hgfs/ndk/android-ndk-r21b

编译

说明
https://puerts.github.io/docs/puerts/unity/performance/il2cpp/

编译android+arm64

cd unity/native_src_il2cpp
node ../cli make --platform android --arch arm64

等待许久,报错了

[11%] Building CXX object CMakeFiles/puerts_il2cpp.dir/Src/Puerts.cpp.o

/mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DEXPERIMENTAL_IL2CPP_PUERTS -DPLATFORM_ANDROID_ARM64 -DV8_94_OR_NEWER -I/mnt/hgfs/puerts/unity/native_src_il2cpp/Inc -I/mnt/hgfs/puerts/unity/native_src_il2cpp/../Assets/core/upm/Plugins/puerts_il2cpp -I/mnt/hgfs/puerts/unity/native_src_il2cpp/../native_src/.backends/v8_9.4/Inc -I/mnt/hgfs/puerts/unity/native_src_il2cpp/../native_src/Inc -I/mnt/hgfs/puerts/unity/native_src_il2cpp/../../unreal/Puerts/Source/JsEnv/Private -I/mnt/hgfs/puerts/unity/native_src_il2cpp/../../unreal/Puerts/ThirdParty/Include/websocketpp -I/mnt/hgfs/puerts/unity/native_src_il2cpp/../../unreal/Puerts/ThirdParty/Include/asio -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -O2 -DNDEBUG  -std=gnu++14 -fPIC -MD -MT CMakeFiles/puerts_il2cpp.dir/Src/Puerts.cpp.o -MF CMakeFiles/puerts_il2cpp.dir/Src/Puerts.cpp.o.d -o CMakeFiles/puerts_il2cpp.dir/Src/Puerts.cpp.o -c /mnt/hgfs/puerts/unity/native_src_il2cpp/Src/Puerts.cpp

/mnt/hgfs/puerts/unity/native_src_il2cpp/Src/Puerts.cpp:181:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    Obj->Set(Context, POEnv->SymbolCSPtr.Get(Isolate), v8::External::New(Context->GetIsolate(), runtimeObject));
    ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


clang++: error: unable to execute command: Killed
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Android (6317467 based on r365631c1) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project e0caee08e5f09b374a27a676d04978c81fcb1928) (based on LLVM 9.0.8svn)
Target: aarch64-none-linux-android21
Thread model: posix
InstalledDir: /mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin
clang++: note: diagnostic msg: PLEASE submit a bug report to https://github.com/android-ndk/ndk/issues and include the crash backtrace, preprocessed source, and associated run script.

百度了一下,是因为swap空间不足,故增加一个swap file
https://zhuanlan.zhihu.com/p/510257476
增加后:

[root@localhost ~]# swapon --show
NAME           TYPE      SIZE USED PRIO
/dev/nvme0n1p2 partition   2G   0B   -2
/swapfile      file       16G   0B   -3

再编译后成功生成:puerts/unity/Assets/core/upm/Plugins/Android/libs/arm64-v8a/libpuerts_il2cpp.a

编译android+armv7

root@localhost puerts]# ./build.sh
node --loader ts-node/esm /mnt/hgfs/puerts/unity/cli/cmd.mts make --platform android --arch armv7
(node:4243) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)

cmake --version

[Puer] download skip: v8_9.4 already exists 

cmake -DBACKEND_DEFINITIONS="V8_94_OR_NEWER" -DBACKEND_LIB_NAMES="/Lib/Android/armeabi-v7a/libwee8.a" -DBACKEND_INC_NAMES="/Inc" -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DJS_ENGINE=v8_9.4 -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=armeabi-v7a -H. -B/mnt/hgfs/puerts/unity/native_src_il2cpp/build_android_armv7_v8_9.4 -DCMAKE_TOOLCHAIN_FILE=/mnt/hgfs/ndk/android-ndk-r21b/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=android-21 -DANDROID_TOOLCHAIN=clang -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang

-- Check for working C compiler: /mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - broken

CMake Error at /usr/local/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/mnt/hgfs/puerts/unity/native_src_il2cpp/build_android_armv7_v8_9.4/CMakeFiles/CMakeScratch/TryCompile-GvSIHC'
    
    Run Build Command(s): /usr/local/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_15833/fast
    /usr/bin/gmake  -f CMakeFiles/cmTC_15833.dir/build.make CMakeFiles/cmTC_15833.dir/build
    gmake[1]: Entering directory '/mnt/hgfs/puerts/unity/native_src_il2cpp/build_android_armv7_v8_9.4/CMakeFiles/CMakeScratch/TryCompile-GvSIHC'
    Building C object CMakeFiles/cmTC_15833.dir/testCCompiler.c.o
    /mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --gcc-toolchain=/mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/sysroot   -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security   -fPIE -MD -MT CMakeFiles/cmTC_15833.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_15833.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_15833.dir/testCCompiler.c.o -c /mnt/hgfs/puerts/unity/native_src_il2cpp/build_android_armv7_v8_9.4/CMakeFiles/CMakeScratch/TryCompile-GvSIHC/testCCompiler.c
    Linking C executable cmTC_15833
    /usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_15833.dir/link.txt --verbose=1
    /mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --gcc-toolchain=/mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security   -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections   CMakeFiles/cmTC_15833.dir/testCCompiler.c.o -o cmTC_15833  -latomic -lm
    /mnt/hgfs/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: fatal error: cmTC_15833: Input/output error
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[1]: *** [CMakeFiles/cmTC_15833.dir/build.make:100: cmTC_15833] Error 1
    gmake[1]: Leaving directory '/mnt/hgfs/puerts/unity/native_src_il2cpp/build_android_armv7_v8_9.4/CMakeFiles/CMakeScratch/TryCompile-GvSIHC'
    gmake: *** [Makefile:127: cmTC_15833/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:10 (project)



-- Configuring incomplete, errors occurred!

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

AssertionError [ERR_ASSERTION]: 0 == 1
    at Object.hook (file:///mnt/hgfs/puerts/unity/cli/make.mts:19:24)
    at runPuertsMake (file:///mnt/hgfs/puerts/unity/cli/make.mts:201:34) {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: 0,
  expected: 1,
  operator: '=='
}

Node.js v20.12.2

又出现input/output的问题,这次应该和swap分区没关系了,看到下面这篇文章
http://t.csdnimg.cn/QArGJ
受其启发,我确实是把puerts工程通过共享文件夹并挂载到mnt后进行编译的,会不会与此有关?于是把工程copy到usr/works里再试试,果然编译成功:

[root@localhost armeabi-v7a]# ls -l /usr/works/unity/Assets/core/upm/Plugins/Android/libs/armeabi-v7a/libpuerts_il2cpp.a
-rw-r--r--. 1 root root 146860860 May  8 19:13 /usr/works/unity/Assets/core/upm/Plugins/Android/libs/armeabi-v7a/libpuerts_il2cpp.a

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...