Я создаю библиотеки Boost C ++ для Android. Я уже тестировал boost :: chrono, и он работает просто отлично.
Но у меня проблема при использовании boost :: filesystem :: current_path (); Он только возвращает "/"
Есть что-то, что я пропустил? Я использую Boost 1.72
CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
#-----------------------------------------
add_library (native-lib SHARED
src/main/cpp/native-lib.cpp)
#-----------------------------------------
add_library (boost_system SHARED IMPORTED)
set_target_properties (boost_system PROPERTIES IMPORTED_LOCATION
${MY_BOOST_LIBS_DIR}/${ANDROID_ABI}/libboost_system.so
)
#-----------------------------------------
add_library (boost_chrono SHARED IMPORTED)
set_target_properties (boost_chrono PROPERTIES IMPORTED_LOCATION
${MY_BOOST_LIBS_DIR}/${ANDROID_ABI}/libboost_chrono.so
)
#-----------------------------------------
add_library (boost_filesystem SHARED IMPORTED)
set_target_properties (boost_filesystem PROPERTIES IMPORTED_LOCATION
${MY_BOOST_LIBS_DIR}/${ANDROID_ABI}/libboost_filesystem.so
)
#-----------------------------------------
include_directories (${MY_BOOST_INC_DIR}
)
#-----------------------------------------
find_library (log-lib log)
#-----------------------------------------
target_link_libraries( # Specifies the target library.
native-lib
${log-lib}
boost_system
boost_chrono
boost_filesystem
)
build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
def my_boost_dir = jniLibs("boost.dir")
def my_boost_dir_libs = my_boost_dir + "/libs"
def my_boost_dir_inc = my_boost_dir + "/include"
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.radu"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//=================================================================//
externalNativeBuild {
cmake {
cppFlags "-std=c++17"
// this causes libc++_shared.so to get packaged into .apk
arguments '-DANDROID_STL=c++_shared'
// This is used in CMakeLists.txt so our native code can find/use (prebuilt) boost
arguments '-DMY_BOOST_LIBS_DIR=' + my_boost_dir_libs
arguments '-DMY_BOOST_INC_DIR=' + my_boost_dir_inc
}
}
ndk {
'abiFilters' x86 '} // ======== ================================================== ======= //}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path file('CMakeLists.txt')
}
}
sourceSets {
main {
jniLibs.srcDirs = [
my_boost_dir_libs
]
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
def jniLibs(key) {
def val = null
if (key == "boost.dir")
val ="${projectDir}/src/main/jniLibs/ndk_21_boost_1.72.0"
else if(val == null)
throw new GradleException("""\
cant find value '${key}' in file 'local.properties'. """)
return val
}