Dependent librariesΒΆ
Dependent shared libraries on Android will be uploaded automatically and
LD_LIBRARY_PATH
will be updated before running executable:
add_executable(gauze_deps main.cpp)
target_link_libraries(gauze_deps PUBLIC gauze_deplib)
gauze_add_test(NAME gauze_deps COMMAND gauze_deps)
if(WIN32 OR CYGWIN)
set(new_path "")
foreach(target gauze_deplib)
list(APPEND new_path $<TARGET_FILE_DIR:${target}>)
endforeach()
list(APPEND new_path $ENV{PATH})
if(WIN32)
string(REPLACE ";" "\;" new_path "${new_path}")
elseif(CYGWIN)
string(REPLACE ";" ":" new_path "${new_path}")
else()
message(FATAL_ERROR "Unreachable")
endif()
set_tests_properties(
gauze_deps PROPERTIES ENVIRONMENT "PATH=${new_path}"
)
endif()
Calling C++ function from library:
#include <cstdlib> // EXIT_SUCCESS
#include <iostream> // std::cout
#include <gauze/deplib/Deplib.hpp>
int gauze_main(int argc, char** argv) {
gauze::deplib::Deplib deplib;
std::cout << "Result: " << deplib.result() << std::endl;
return EXIT_SUCCESS;
}
Run test (you should build with BUILD_SHARED_LIBS=ON
):
4: Creating directory on Android device: '/data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon/lib'
4: Uploading dependent libraries to Android device
4: '/.../test/gauze/deplib/libgauze_deplib.so'
4: -> '/data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon/lib/libgauze_deplib.so'
4: Set LD_LIBRARY_PATH to '/data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon/lib'
4: Run command on Android device:
4: [/data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon]> "/data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon/bin/gauze_deps"
4: Command output (with exit code):
4: *** BEGIN ***
4: Result: 42
4: 0
4: *** END ***
4: Done
1/1 Test #4: gauze_deps ....................... Passed 2.13 sec