diff options
Diffstat (limited to 'android-app/app/src/main/cpp')
| -rw-r--r-- | android-app/app/src/main/cpp/CMakeLists.txt | 59 | ||||
| -rw-r--r-- | android-app/app/src/main/cpp/native-lib.cpp | 14 |
2 files changed, 73 insertions, 0 deletions
diff --git a/android-app/app/src/main/cpp/CMakeLists.txt b/android-app/app/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000..9147ce6 --- /dev/null +++ b/android-app/app/src/main/cpp/CMakeLists.txt @@ -0,0 +1,59 @@ +# Sets the minimum version of CMake required to build your native library. +# This ensures that a certain set of CMake features is available to +# your build. + +cmake_minimum_required(VERSION 3.4.1) + +# Declares and names the project. +project("wind_visualization_native") + +# Creates and names a library, sets it as either STATIC or SHARED, and +# specifies the source files. +# The wind_visualization_native library will be built as a shared library +# and will include the C++ source file `native-lib.cpp`. +add_library( # Sets the name of the library. + wind_visualization_native + + # Sets the library as a shared library. + SHARED + + # Provides a relative path to your source file(s). + native-lib.cpp ) # Corrected path + +# Searches for a prebuilt static library called 'maplibre' which contains the +# MapLibre GL Native custom layer host implementation. This library is usually +# provided by the MapLibre Android SDK. +find_library( # Sets the name of the path variable. + maplibre-gl-lib + + # Specifies the name of the NDK library that + # CMake should locate. + maplibre ) # Searching for libmaplibre.so + +# Searches for the Android log library. +find_library( # Sets the name of the path variable. + log-lib + + # Specifies the name of the NDK library that + # CMake should locate. + log ) + +# Specifies paths to the header files of a library. +# For example, the MapLibre GL Native SDK headers might be in a +# directory like 'src/main/cpp/maplibre-gl-native-headers'. +# You would add that path here. +# For now, let's just assume we will need JNI headers. +target_include_directories(wind_visualization_native PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + # Add JNI specific include directories if needed, typically handled by Android Gradle Plugin + ) + +# Specifies libraries that CMake should link to your target library. +# This includes the MapLibre GL Native library and the logging library. +target_link_libraries( # Specifies the target library. + wind_visualization_native + + # Links the target library to the log library + # included in the NDK. + ${maplibre-gl-lib} + ${log-lib} ) diff --git a/android-app/app/src/main/cpp/native-lib.cpp b/android-app/app/src/main/cpp/native-lib.cpp new file mode 100644 index 0000000..f606a41 --- /dev/null +++ b/android-app/app/src/main/cpp/native-lib.cpp @@ -0,0 +1,14 @@ +#include <jni.h> +#include <string> +#include <android/log.h> + +#define TAG "WindVisualizationNative" + +extern "C" JNIEXPORT jstring JNICALL +Java_org_terst_nav_MainActivity_stringFromJNI( + JNIEnv* env, + jobject /* this */) { + std::string hello = "Hello from C++"; + __android_log_print(ANDROID_LOG_INFO, TAG, "stringFromJNI called!"); + return env->NewStringUTF(hello.c_str()); +} |
