Build instructions
d3xMachina opened this issue · 4 comments
Hello,
Could you tell me how to build this project ? Thank you!
Translated with Deepl :
您好、
能告诉我如何制作这个项目吗?谢谢!
I tried on both Windows 11 and on a debian 12 VM and I'm having the same error message. I would like to build a "zygisk_module.zip" like in the release page.
Here is what I did on Debian :
- I installed Android NDK and confirmed it works (ndk-build --version command works) by following instructions here
- I installed CMake
sudo apt install cmake
- I built absl following official instructions here :
cd ~/android/src
git clone https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
mkdir build && cd build
cmake -DABSL_BUILD_TESTING=ON -DABSL_USE_GOOGLETEST_HEAD=ON -DCMAKE_CXX_STANDARD=14 ..
cmake --build . --target all
ctest command confirms every tests succeeded for absl
- I tried to build this project :
git clone https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
mkdir build && cd build
cmake -Dabsl_DIR=~/android/src/abseil-cpp/build -DCMAKE_BUILD_TYPE=Release ..
I get the error :
-- Release Version
-- CMAKE_PREFIX_PATH:/x86_64-linux-gnu
CMake Error at /home/dev/android/src/abseil-cpp/build/abslConfig.cmake:32 (include):
include could not find requested file:
/home/dev/android/src/abseil-cpp/build/abslTargets.cmake
Call Stack (most recent call first):
UnityFPSUnlocker/CMakeLists.txt:64 (find_package)-- Configuring incomplete, errors occurred!
The abslConfig.cmake in the absl build directory has the line :
include ("${CMAKE_CURRENT_LIST_DIR}/abslTargets.cmake")
but the abslTargets.cmake file doesn't exist.
Also in the CMakeLists.txt of this project there is :
find_library(log-lib log)
How to get this dependency ?
My bad, my description is not detailed enough. I am using VSCode for development, but if you're building from the command line, it is a bit complex.
For windows:
Download the source codes for absl-cpp
and UnityFPSUnlocker
, and unzip them into the same directory (for example, D:\UnityFPSUnlocker-zygisk_module).
tree -n -d -L 1
.
├── abseil-cpp-20230802.1
└── UnityFPSUnlocker
First, build absl
cd abseil-cpp-20230802.1
mkdir build
cd build
set environment
set ABI=arm64-v8a
set ANDROID_NDK=D:\android-ndk-r25c
and build
cmake -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%/build/cmake/android.toolchain.cmake -DANDROID_ABI=%ABI% -DCMAKE_ANDROID_ARCH_ABI=%ABI% -DANDROID_PLATFORM=android-28 -DANDROID_NDK=%ANDROID_NDK% -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Release -GNinja ../
cmake --build . --config Release
install to sysroot
cmake --install . --prefix %ANDROID_NDK%/toolchains\llvm\prebuilt\windows-x86_64\sysroot\aarch64-linux-android\absl
now build UnityFPSUnlocker
cd D:\UnityFPSUnlocker-zygisk_module\UnityFPSUnlocker
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%/build/cmake/android.toolchain.cmake -DANDROID_ABI=%ABI% -DCMAKE_ANDROID_ARCH_ABI=%ABI% -DANDROID_PLATFORM=android-28 -DANDROID_NDK=%ANDROID_NDK% -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Release -GNinja ../
cmake --build . --config Release
after last command, you'd see this output:
D:\UnityFPSUnlocker-zygisk_module\UnityFPSUnlocker\build>cmake --build . --config Release
[13/13] Linking CXX shared library D:\UnityFPSUnlocker-zygisk_module\UnityFPSUnlocker\libs\arm64-v8a\libUnityFPSUnlocker.so
I'm not use gradle, so you need to replace this binary file manually.
Rename D:\UnityFPSUnlocker-zygisk_module\UnityFPSUnlocker\libs\arm64-v8a\libUnityFPSUnlocker.so
to arm64-v8a.so
and replace it to zygisk_module.zip/zygisk/arm64-v8a.so
Thanks for the instructions, I've managed to build it. I had to download and set ninja too.
I've made a batch script to build every ".so" and rename them correctly. They are put in "UnityFPSUnlocker\libs".
Your tree must look like :
.
│ build.bat
│ ninja.exe
│
├───abseil-cpp
├───android-ndk
└───UnityFPSUnlocker
I got ninja.exe from the archive here.
Here is the script (save as a build.bat) :
@echo off
set "SCRIPT_DIR=%~dp0"
set BUILD_TYPE=Release
set "ARCH_LIST=arm64-v8a:aarch64-linux-android armeabi-v7a:arm-linux-androideabi x86_64:x86_64-linux-android x86:i686-linux-android"
set PLATFORM=android-28
set "ANDROID_NDK=%SCRIPT_DIR%\android-ndk"
set "ABSL_BUILD_DIR=%SCRIPT_DIR%\abseil-cpp\build"
set "APP_BUILD_DIR=%SCRIPT_DIR%\UnityFPSUnlocker\build"
set "APP_LIB_DIR=%SCRIPT_DIR%\UnityFPSUnlocker\libs"
set "NINJA_PATH=%SCRIPT_DIR%\ninja.exe"
set "ANDROID_NDK_SYSROOT=%ANDROID_NDK%\toolchains\llvm\prebuilt\windows-x86_64\sysroot"
cmake --version >nul
if %ERRORLEVEL% NEQ 0 (
echo CMake is not installed!
goto :END
)
call :START %ARCH_LIST%
goto :END
:START
set "ARCH=%1"
if "%ARCH%"=="" exit /b
shift
set "ABI="
set "ABSL_INSTALL_DIR="
for /f "tokens=1,2 delims=:" %%a in ("%ARCH%") do (
set "ABI=%%a"
set "ABSL_INSTALL_DIR=%ANDROID_NDK_SYSROOT%\%%b\absl"
)
if "%ABI%"=="" goto :ERROR
if "%ABSL_INSTALL_DIR%"=="" goto :ERROR
:CLEANUP
echo Cleaning up (%ABI%)...
del "%APP_LIB_DIR%\%ABI%.so" >nul
if exist "%ABSL_BUILD_DIR%" (
rmdir /s /q "%ABSL_BUILD_DIR%" >nul
)
if exist "%ABSL_INSTALL_DIR%" (
rmdir /s /q "%ABSL_INSTALL_DIR%" >nul
)
if exist "%APP_BUILD_DIR%" (
rmdir /s /q "%APP_BUILD_DIR%" >nul
)
:BUILD_ABSL
echo Setting up abseil (%ABI%)...
mkdir "%ABSL_BUILD_DIR%" >nul
cd "%ABSL_BUILD_DIR%"
cmake "-DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%\build\cmake\android.toolchain.cmake" -DANDROID_ABI=%ABI% -DCMAKE_ANDROID_ARCH_ABI=%ABI% -DANDROID_PLATFORM=%PLATFORM% "-DANDROID_NDK=%ANDROID_NDK%" -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -GNinja "-DCMAKE_MAKE_PROGRAM=%NINJA_PATH%" ../
if %ERRORLEVEL% NEQ 0 goto :ERROR
echo.
echo Building abseil (%ABI%)...
cmake --build . --config %BUILD_TYPE%
if %ERRORLEVEL% NEQ 0 goto :ERROR
echo Installing abseil (%ABI%)...
cmake --install . --prefix "%ABSL_INSTALL_DIR%"
if %ERRORLEVEL% NEQ 0 goto :ERROR
:BUILD_APP
echo.
echo Setting up UnityFPSUnlocker (%ABI%)...
mkdir "%APP_BUILD_DIR%" >nul
cd "%APP_BUILD_DIR%"
cmake "-DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%\build\cmake\android.toolchain.cmake" -DANDROID_ABI=%ABI% -DCMAKE_ANDROID_ARCH_ABI=%ABI% -DANDROID_PLATFORM=%PLATFORM% "-DANDROID_NDK=%ANDROID_NDK%" -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -GNinja "-DCMAKE_MAKE_PROGRAM=%NINJA_PATH%" ../
if %ERRORLEVEL% NEQ 0 goto :ERROR
echo.
echo Building UnityFPSUnlocker (%ABI%)...
cmake --build . --config %BUILD_TYPE%
if %ERRORLEVEL% NEQ 0 goto :ERROR
cd "%APP_LIB_DIR%"
move "%ABI%\libUnityFPSUnlocker.so" "%ABI%.so"
rmdir "%APP_LIB_DIR%\%ABI%"
:SUCCESS
echo.
echo Operation success (%ABI%)!
goto :START
:ERROR
echo.
echo Operation failed (%ABI%)!
exit /b
:END
echo.
pause