-
Notifications
You must be signed in to change notification settings - Fork 0
Build Script Overview
The build_cpp.sh script is the heart of the library. Its purpose is to cross-compile GDAL and all of its C/C++ dependencies for each of the Android architectures required by the app.
-
Architecture Loops: The script contains a main loop that iterates four times, once for each target Android architecture:
armeabi-v7a,arm64-v8a,x86, andx86_64. -
build_for_targetFunction: Inside the loop, a master function namedbuild_for_targetis called. This function does the following for the given architecture:- Sets up environment variables (
CC,CXX,CFLAGS,LDFLAGS, etc.) to point to the correct compiler and toolchain from the Android NDK. - Defines an "install" directory (e.g.,
build/arm64-v8a) where all the compiled libraries and headers for that specific architecture will be placed.
- Sets up environment variables (
-
Building Dependencies: The function then proceeds to build each dependency in sequence (e.g., PROJ, GEOS, SQLite, libpng). For each dependency, it runs its
configureorcmakescript with a--prefixflag pointing to the architecture-specific "install" directory. This ensures the compiled output is placed in the correct location. -
Building GDAL: Once all dependencies are built and "installed" into the
build/subdirectory, the script configures and builds GDAL itself. The GDALconfigurescript is pointed to the same "install" directory, allowing it to find the headers and libraries of all its dependencies. -
Final Output: The process results in a complete set of
.so(shared object) files for each architecture. These are the final product of the script and are then copied into the Android project'sgdal/src/main/jniLibsdirectory, where they are bundled by Gradle into the final APK.