How to install NDK for building engine from source

I want to build Bob from source, on the Windows platform building for Android, so that I can investigate https://github.com/defold/defold/issues/5630

I’ve followed the setup instructions in README_BUILD.md, README_ANDROID.md and README_SETUP_WINDOWS.md but something isn’t working.

Running these commands:

cd d:/defold
./scripts/build.py shell
cd d:/defold
./scripts/build.py install_ext --platform=armv7-android --package-path=./packages/
./scripts/build.py build_engine --platform=armv7-android

build_engine fails with:

At least one compiler (g++, …) must be selected

Prior to that it outputs

Checking for program gcc,cc : ok d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/win32-x86_64/bin/armv7a-linux-androideabi16-clang

but that path doesn’t seem to exist.
README_ANDROID.md states

  • The Android NDK is managed as a package and automatically installed via install_ext from the build.py script

but there’s no evidence that the NDK has been installed, unless I need to call install_ext again with some other parameter?

1 Like

At the top of the README_BUILD.md it lists the prerequisite of packaged sdk’s.

That document links to this document where it menitons you should package your SDK/NDK using the ./scripts/package/package_android_ndk.sh/ ./scripts/package/package_android_sdk.sh scripts.

1 Like

In fact I did that step, but hadn’t realised it had failed due to a certificate error in the download, so I modified the script to pass --no-check-certificate to wget.
Then, it failed to unzip the file (it claimed the zip was corrupt, I tried multiple times) so I created the .tar.gz manually.

There’s still a problem - when building, the following is output

Checking for program gcc,cc : ok d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/win32-x86_64/bin/armv7a-linux-androideabi16-clang

whereas llvm is actually located at
D:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20\toolchains\llvm\prebuilt \windows-x86_64\bin\armv7a-linux-androideabi16-clang

However, I’d overlooked packaging the Android SDK.
That initially failed for the same reason (wget failing, in this case silently), and then (running with MinGW) the script tries to run sdkmanager but in the Windows Android tools of course sdkmanager is a .bat file, so I ran that manually.
The final problem is that the packaged file has the wrong name because TOOLHOSTNAME is embedded in the filename and is “mingw32_nt” not “windows”.

3 Likes

Yeah, writing these scripts (and maintaining them) is time consuming.
Updating them usually only takes place when we need to update an sdk version.
Every bit helps ofc, and we’ll happily accept pull requests for improvements.

2 Likes

The one that’s really causing me trouble is this:

Correcting that, leads to this:

Output

Waf: Leaving directory `d:\defold\engine\dlib\build’
At least one compiler (g++, …) must be selected
None
Traceback (most recent call last):
File “./scripts/build.py”, line 2227, in
f()
File “./scripts/build.py”, line 1102, in build_engine
self._build_engine_lib(args, lib, target_platform)
File “./scripts/build.py”, line 1039, in _build_engine_lib
run.env_command(self._form_env(), args + plf_args + self.waf_options + skip_build_tests, cwd = cwd)
File “d:\defold\build_tools\run.py”, line 77, in env_command
return _exec_command(args, shell = False, stdout = None, env = env, **kwargs)
File “d:\defold\build_tools\run.py”, line 55, in _exec_command
raise ExecException(process.returncode, output)
run.ExecException

which is similar to this thread where your advice was to print the environment, which leads to this:

Summary

‘AR’ ‘d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ar’
‘BOB_BUILD_PLATFORM’ ‘armv7-android’
‘BUILD_PLATFORM’ ‘x86_64-win32’
‘CC’ ‘d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi16-clang’
‘CCACHE’ ‘’
‘CPP’ ‘d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi16-clang -E’
‘CXX’ ‘d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi16-clang++’
‘DX’ ‘d:\defold\tmp\dynamo_home\ext\SDKs/android-sdk/build-tools/30.0.3/dx’
‘DYNAMO_HOME’ ‘d:\defold\tmp\dynamo_home’
‘LD’ ‘d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ld’
‘LINK_CXX’ ‘d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi16-clang++’
‘PLATFORM’ ‘armv7-android’
‘PREFIX’ ‘d:\defold\tmp\dynamo_home’
‘RANLIB’ ‘d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ranlib’
‘VALGRIND’ ‘’
Checking for program gcc,cc : ok d:\defold\tmp\dynamo_home\ext\SDKs\android-ndk-r20/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi16-clang
Checking for msvc : ok
Checking for program javac : ok D:\Installs\jdk-11.0.1\bin\javac.exe
Checking for program java : ok D:\Installs\jdk-11.0.1\bin\java.exe
Checking for program jar : ok D:\Installs\jdk-11.0.1\bin\jar.exe

Unlike the situation in the other thread, the compiler does exist at that path. I assume the mixed paths are OK because I ran Process Monitor and the file is being accessed.

There’s a comment in waf_dynamo.pf which seems relevant because it’s the absence of CXX_NAME that triggers the error - any idea what might be happening under the hood?

#NOTE: We override after check_tool. Otherwise waf gets confused and CXX_NAME etc are missing…

edit: Change of plan - I’m giving WSL a try.

1 Like