Hello, I use your distribution of LuaJIT as part of the https://github.com/bjornbytes/lovr game development library, which includes your LuaJIT as a a CMake add_subdirectory
. The CMake file in your distribution is extremely useful and works much better than the bodged one we used before. I have successfully used it to build on MacOS, build on Windows, and to cross-compile an Android version from a MacOS build machine.
Today I tried to use it to cross-compile an Android version from a Windows build machine. But it failed, and it failed because of a very small, fiddly configuration issue. The final lines of the build were:
C:\Users\Andi\work\g\lovr\deps\luajit\src\host\minilua.c(7617,1): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\Andi\work\g\lovr\build-apk\luajit\src\minilua\minilua.vcxproj]
C:\Users\Andi\work\g\lovr\deps\luajit\src\host\minilua.c(7633,1): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\Andi\work\g\lovr\build-apk\luajit\src\minilua\minilua.vcxproj]
minilua.vcxproj -> C:\Users\Andi\work\g\lovr\build-apk\luajit\src\minilua\Debug\minilua.exe
Building Custom Rule C:/Users/Andi/work/g/lovr/deps/luajit/src/host/cmake/minilua/CMakeLists.txt
[236/470] Generating buildvm_arch.h
FAILED: luajit/src/buildvm_arch.h C:/Users/Andi/work/g/lovr/build-apk/luajit/src/buildvm_arch.h
cmd.exe /C "cd /D C:\Users\Andi\work\g\lovr\build-apk\luajit\src && C:\Users\Andi\work\g\lovr\build-apk\luajit\src\minilua\minilua.exe C:/Users/Andi/work/g/lovr/deps/luajit/src/../dynasm/dynasm.lua -D FPU -D HFABI -D ENDIAN_LE -D P64 -D FFI -D JIT -D DUALNUM -D VER= -o C:/Users/Andi/work/g/lovr/build-apk/luajit/src/buildvm_arch.h C:/Users/Andi/work/g/lovr/deps/luajit/src/vm_arm64.dasc"
'C:\Users\Andi\work\g\lovr\build-apk\luajit\src\minilua\minilua.exe' is not recognized as an internal or external command,
operable program or batch file.
[241/470] Building CXX object glslang/SPIRV/CMakeFiles/SPIRV.dir/GlslangToSpv.cpp.o
ninja: build stopped: subcommand failed.
Looking carefully, what went wrong is clear: It builds the helper C:\Users\Andi\work\g\lovr\build-apk\luajit\src\minilua\Debug\minilua.exe
. Then it attempts to execute C:\Users\Andi\work\g\lovr\build-apk\luajit\src\minilua\minilua.exe
. Notice the Debug\ directory. The MSVC generator for cmake likes to put exes inside a Debug\ or Release\ subdirectory. However the .exe is then being invoked by (I think) the Ninja generator, which does not include that Debug/Release subdirectory when constructing the path it attempts to run minilua.exe from.
Is there some way to fix this?
Here is my command line build invocation, unfortunately in addition to being somewhat specific to my own machine it's a build invocation for lovr and not luajit directly:
set ANDROID_HOME=%LOCALAPPDATA%\Android\Sdk
set JAVA_HOME=C:\Users\Andi\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\221.6008.13.2211.9619390\jbr
set PATH=%PATH:C:\Program Files\CMake\bin;=%
set PATH=%ANDROID_HOME%\cmake\3.22.1\bin;%PATH%
cmake.exe ^
-G Ninja ^
-DANDROID=1 ^
-DCMAKE_TOOLCHAIN_FILE=%ANDROID_HOME%\ndk\21.0.6113669\build\cmake\android.toolchain.cmake ^
-DANDROID_SDK=%ANDROID_HOME% ^
-DANDROID_ABI=arm64-v8a ^
-DANDROID_NATIVE_API_LEVEL=23 ^
-DANDROID_BUILD_TOOLS_VERSION=33.0.1 ^
-DANDROID_KEYSTORE=C:\(REDACTED) ^
-DANDROID_KEYSTORE_PASS=(REDACTED) ^
-DANDROID_ASSETS=C:\Users\Andi\work\lv\lodr ^
-DANDROID_PACKAGE=com.mermaid.test.skategirl_hotswap ^
-DLOVR_APK_NAME=skategirl_hotswap ^
-DUSE_PUREDATA=YES -DLOVR_ENABLE_PHYSICS=NO ^
-DCMAKE_BUILD_TYPE=Release ^
..
This is building with WolhSoft LuaJIT 113eb1d
(Notice minilua is being build debug despite me having picked BUILD_TYPE Release, but this hardly matters.)